Skip to content

Commit 464af68

Browse files
committed
Remove format from syntax_bridge hot path
1 parent 0ecdba2 commit 464af68

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

crates/ra_mbe/src/syntax_bridge.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -607,12 +607,13 @@ impl<'a> TreeSink for TtTreeSink<'a> {
607607
let text: SmolStr = match self.cursor.token_tree() {
608608
Some(tt::TokenTree::Leaf(leaf)) => {
609609
// Mark the range if needed
610-
let id = match leaf {
611-
tt::Leaf::Ident(ident) => ident.id,
612-
tt::Leaf::Punct(punct) => punct.id,
613-
tt::Leaf::Literal(lit) => lit.id,
610+
let (text, id) = match leaf {
611+
tt::Leaf::Ident(ident) => (ident.text.clone(), ident.id),
612+
tt::Leaf::Punct(punct) => {
613+
(SmolStr::new_inline_from_ascii(1, &[punct.char as u8]), punct.id)
614+
}
615+
tt::Leaf::Literal(lit) => (lit.text.clone(), lit.id),
614616
};
615-
let text = SmolStr::new(format!("{}", leaf));
616617
let range = TextRange::offset_len(self.text_pos, TextUnit::of_str(&text));
617618
self.token_map.insert(id, range);
618619
self.cursor = self.cursor.bump();

0 commit comments

Comments
 (0)