# HG changeset patch # User Simon Heath # Date 1689677315 14400 # Tue Jul 18 06:48:35 2023 -0400 # Branch devel # Node ID 30675ced262ab3fbe0574f7724840b655f291ed1 # Parent 24722db3fc92738e8277c74248036d36ab75adc5 turns out cloning the parser is expensive diff --git a/src/parser.rs b/src/parser.rs --- a/src/parser.rs +++ b/src/parser.rs @@ -1370,9 +1370,9 @@ /// If this can't parse a valid type, it will rewind /// back to where it started. Magic! - /// Also, you know, arbitrary lookahead, but that's ok. + /// Also, you know, arbitrary lookahead/backtracking, but that's ok. fn try_parse_type(&mut self) -> Option { - let old_parser = self.clone(); + let old_lexer = self.lex.clone(); let t = self.next()?; let x = match t.kind { T::Ident(ref s) => { @@ -1409,7 +1409,9 @@ } _ => { // Wind the parse stream back to wherever we started - *self = old_parser; + // TODO LATER: We should maybe think about making a better way + // of doing this, but so far this is the only place it happens. + self.lex = old_lexer; return None; } };