mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-20 16:11:35 +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;
|
type Rule = Rule;
|
||||||
|
|
||||||
fn from_pest(pest: &mut Pairs<'ast, Rule>) -> Result<Self, ConversionError<Void>> {
|
fn from_pest(pest: &mut Pairs<'ast, Rule>) -> Result<Self, ConversionError<Void>> {
|
||||||
let mut clone = pest.clone();
|
let pair = pest.peek().ok_or(::from_pest::ConversionError::NoMatch)?;
|
||||||
let pair = clone.next().ok_or(::from_pest::ConversionError::NoMatch)?;
|
|
||||||
match pair.as_rule() {
|
match pair.as_rule() {
|
||||||
Rule::expression => {
|
Rule::expression => {
|
||||||
// Transfer iterated state to pest.
|
// advance the iterator
|
||||||
*pest = clone;
|
pest.next();
|
||||||
Ok(PRECEDENCE_CLIMBER.climb(pair.into_inner(), parse_term, binary_expression))
|
Ok(PRECEDENCE_CLIMBER.climb(pair.into_inner(), parse_term, binary_expression))
|
||||||
}
|
}
|
||||||
_ => Err(ConversionError::NoMatch),
|
_ => Err(ConversionError::NoMatch),
|
||||||
|
Loading…
Reference in New Issue
Block a user