mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-19 23:52:02 +03:00
perf: don't clone the pest iterator when parsing
Signed-off-by: ljedrz <ljedrz@gmail.com>
This commit is contained in:
parent
61556cca29
commit
5fbbf5e978
@ -159,12 +159,11 @@ impl<'ast> FromPest<'ast> for Expression<'ast> {
|
||||
type Rule = Rule;
|
||||
|
||||
fn from_pest(pest: &mut Pairs<'ast, Rule>) -> Result<Self, ConversionError<Void>> {
|
||||
let mut clone = pest.clone();
|
||||
let pair = clone.next().ok_or(::from_pest::ConversionError::NoMatch)?;
|
||||
let pair = pest.peek().ok_or(::from_pest::ConversionError::NoMatch)?;
|
||||
match pair.as_rule() {
|
||||
Rule::expression => {
|
||||
// Transfer iterated state to pest.
|
||||
*pest = clone;
|
||||
// advance the iterator
|
||||
pest.next();
|
||||
Ok(PRECEDENCE_CLIMBER.climb(pair.into_inner(), parse_term, binary_expression))
|
||||
}
|
||||
_ => Err(ConversionError::NoMatch),
|
||||
|
Loading…
Reference in New Issue
Block a user