aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe/src
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2020-04-13 18:23:33 +0100
committerEdwin Cheng <[email protected]>2020-04-13 18:23:33 +0100
commit464af68ec56b1b35151acc3b53eea3d3d67e03d3 (patch)
treec1df12e8441fd640e817f0ba143a2eea700e721a /crates/ra_mbe/src
parent0ecdba20df41a800222d0fd864843843feb6e875 (diff)
Remove format from syntax_bridge hot path
Diffstat (limited to 'crates/ra_mbe/src')
-rw-r--r--crates/ra_mbe/src/syntax_bridge.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/crates/ra_mbe/src/syntax_bridge.rs b/crates/ra_mbe/src/syntax_bridge.rs
index 9fb5cb058..31e9b22e7 100644
--- a/crates/ra_mbe/src/syntax_bridge.rs
+++ b/crates/ra_mbe/src/syntax_bridge.rs
@@ -607,12 +607,13 @@ impl<'a> TreeSink for TtTreeSink<'a> {
607 let text: SmolStr = match self.cursor.token_tree() { 607 let text: SmolStr = match self.cursor.token_tree() {
608 Some(tt::TokenTree::Leaf(leaf)) => { 608 Some(tt::TokenTree::Leaf(leaf)) => {
609 // Mark the range if needed 609 // Mark the range if needed
610 let id = match leaf { 610 let (text, id) = match leaf {
611 tt::Leaf::Ident(ident) => ident.id, 611 tt::Leaf::Ident(ident) => (ident.text.clone(), ident.id),
612 tt::Leaf::Punct(punct) => punct.id, 612 tt::Leaf::Punct(punct) => {
613 tt::Leaf::Literal(lit) => lit.id, 613 (SmolStr::new_inline_from_ascii(1, &[punct.char as u8]), punct.id)
614 }
615 tt::Leaf::Literal(lit) => (lit.text.clone(), lit.id),
614 }; 616 };
615 let text = SmolStr::new(format!("{}", leaf));
616 let range = TextRange::offset_len(self.text_pos, TextUnit::of_str(&text)); 617 let range = TextRange::offset_len(self.text_pos, TextUnit::of_str(&text));
617 self.token_map.insert(id, range); 618 self.token_map.insert(id, range);
618 self.cursor = self.cursor.bump(); 619 self.cursor = self.cursor.bump();