minor: Simplify
This commit is contained in:
parent
91200e31e3
commit
8fad24d3c2
@ -192,7 +192,7 @@ fn expand_repeat(
|
|||||||
t.delimiter = None;
|
t.delimiter = None;
|
||||||
push_subtree(&mut buf, t);
|
push_subtree(&mut buf, t);
|
||||||
|
|
||||||
if let Some(ref sep) = separator {
|
if let Some(sep) = separator {
|
||||||
match sep {
|
match sep {
|
||||||
Separator::Ident(ident) => {
|
Separator::Ident(ident) => {
|
||||||
has_seps = 1;
|
has_seps = 1;
|
||||||
|
@ -396,7 +396,7 @@ fn close_delim(&mut self, idx: usize, close_abs_range: Option<TextRange>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A Raw Token (straightly from lexer) convertor
|
/// A raw token (straight from lexer) convertor
|
||||||
struct RawConvertor<'a> {
|
struct RawConvertor<'a> {
|
||||||
lexed: parser::LexedStr<'a>,
|
lexed: parser::LexedStr<'a>,
|
||||||
pos: usize,
|
pos: usize,
|
||||||
@ -525,8 +525,7 @@ enum SynToken {
|
|||||||
impl SynToken {
|
impl SynToken {
|
||||||
fn token(&self) -> &SyntaxToken {
|
fn token(&self) -> &SyntaxToken {
|
||||||
match self {
|
match self {
|
||||||
SynToken::Ordinary(it) => it,
|
SynToken::Ordinary(it) | SynToken::Punch(it, _) => it,
|
||||||
SynToken::Punch(it, _) => it,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -659,7 +658,7 @@ fn token(&mut self, kind: SyntaxKind, mut n_tokens: u8) {
|
|||||||
|
|
||||||
let mut last = self.cursor;
|
let mut last = self.cursor;
|
||||||
for _ in 0..n_tokens {
|
for _ in 0..n_tokens {
|
||||||
let tmp_str: SmolStr;
|
let tmp: u8;
|
||||||
if self.cursor.eof() {
|
if self.cursor.eof() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -669,18 +668,15 @@ fn token(&mut self, kind: SyntaxKind, mut n_tokens: u8) {
|
|||||||
Some(tt::buffer::TokenTreeRef::Leaf(leaf, _)) => {
|
Some(tt::buffer::TokenTreeRef::Leaf(leaf, _)) => {
|
||||||
// Mark the range if needed
|
// Mark the range if needed
|
||||||
let (text, id) = match leaf {
|
let (text, id) = match leaf {
|
||||||
tt::Leaf::Ident(ident) => (&ident.text, ident.id),
|
tt::Leaf::Ident(ident) => (ident.text.as_str(), ident.id),
|
||||||
tt::Leaf::Punct(punct) => {
|
tt::Leaf::Punct(punct) => {
|
||||||
assert!(punct.char.is_ascii());
|
assert!(punct.char.is_ascii());
|
||||||
let char = &(punct.char as u8);
|
tmp = punct.char as u8;
|
||||||
tmp_str = SmolStr::new_inline(
|
(std::str::from_utf8(std::slice::from_ref(&tmp)).unwrap(), punct.id)
|
||||||
std::str::from_utf8(std::slice::from_ref(char)).unwrap(),
|
|
||||||
);
|
|
||||||
(&tmp_str, punct.id)
|
|
||||||
}
|
}
|
||||||
tt::Leaf::Literal(lit) => (&lit.text, lit.id),
|
tt::Leaf::Literal(lit) => (lit.text.as_str(), lit.id),
|
||||||
};
|
};
|
||||||
let range = TextRange::at(self.text_pos, TextSize::of(text.as_str()));
|
let range = TextRange::at(self.text_pos, TextSize::of(text));
|
||||||
self.token_map.insert(id, range);
|
self.token_map.insert(id, range);
|
||||||
self.cursor = self.cursor.bump();
|
self.cursor = self.cursor.bump();
|
||||||
text
|
text
|
||||||
@ -740,7 +736,7 @@ fn start_node(&mut self, kind: SyntaxKind) {
|
|||||||
|
|
||||||
match self.roots.last_mut() {
|
match self.roots.last_mut() {
|
||||||
None | Some(0) => self.roots.push(1),
|
None | Some(0) => self.roots.push(1),
|
||||||
Some(ref mut n) => **n += 1,
|
Some(n) => *n += 1,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user