inline: reuse event buffer between blocks
make sure not to allocate a new buffer on each block
This commit is contained in:
parent
1e5e56c463
commit
9429f90307
3 changed files with 45 additions and 24 deletions
|
|
@ -94,6 +94,13 @@ impl<I: Iterator<Item = char> + Clone> Parser<I> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn reset(&mut self, chars: I) {
|
||||
self.lexer = lex::Lexer::new(chars);
|
||||
self.span = Span::new(0, 0);
|
||||
self.openers.clear();
|
||||
debug_assert!(self.events.is_empty());
|
||||
}
|
||||
|
||||
fn eat(&mut self) -> Option<lex::Token> {
|
||||
let tok = self.lexer.next();
|
||||
if let Some(t) = &tok {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue