mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Remove format from syntax_bridge hot path
This commit is contained in:
parent
0ecdba20df
commit
464af68ec5
1 changed files with 6 additions and 5 deletions
|
@ -607,12 +607,13 @@ impl<'a> TreeSink for TtTreeSink<'a> {
|
||||||
let text: SmolStr = match self.cursor.token_tree() {
|
let text: SmolStr = match self.cursor.token_tree() {
|
||||||
Some(tt::TokenTree::Leaf(leaf)) => {
|
Some(tt::TokenTree::Leaf(leaf)) => {
|
||||||
// Mark the range if needed
|
// Mark the range if needed
|
||||||
let id = match leaf {
|
let (text, id) = match leaf {
|
||||||
tt::Leaf::Ident(ident) => ident.id,
|
tt::Leaf::Ident(ident) => (ident.text.clone(), ident.id),
|
||||||
tt::Leaf::Punct(punct) => punct.id,
|
tt::Leaf::Punct(punct) => {
|
||||||
tt::Leaf::Literal(lit) => lit.id,
|
(SmolStr::new_inline_from_ascii(1, &[punct.char as u8]), punct.id)
|
||||||
|
}
|
||||||
|
tt::Leaf::Literal(lit) => (lit.text.clone(), lit.id),
|
||||||
};
|
};
|
||||||
let text = SmolStr::new(format!("{}", leaf));
|
|
||||||
let range = TextRange::offset_len(self.text_pos, TextUnit::of_str(&text));
|
let range = TextRange::offset_len(self.text_pos, TextUnit::of_str(&text));
|
||||||
self.token_map.insert(id, range);
|
self.token_map.insert(id, range);
|
||||||
self.cursor = self.cursor.bump();
|
self.cursor = self.cursor.bump();
|
||||||
|
|
Loading…
Reference in a new issue