Simplify code.

This commit is contained in:
Stephen Chung 2021-10-18 15:09:07 +08:00
parent b091fea17b
commit 3174b4759e
2 changed files with 7 additions and 11 deletions

View File

@ -2003,14 +2003,12 @@ impl fmt::Debug for Expr {
}
Self::Variable(i, _, x) => {
f.write_str("Variable(")?;
match x.1 {
Some((_, ref namespace)) => write!(f, "{}", namespace)?,
_ => (),
if let Some((_, ref namespace)) = x.1 {
write!(f, "{}", namespace)?
}
f.write_str(&x.2)?;
match i.map_or_else(|| x.0, |n| NonZeroUsize::new(n.get() as usize)) {
Some(n) => write!(f, " #{}", n)?,
_ => (),
if let Some(n) = i.map_or_else(|| x.0, |n| NonZeroUsize::new(n.get() as usize)) {
write!(f, " #{}", n)?
}
f.write_str(")")
}

View File

@ -2722,12 +2722,10 @@ impl Engine {
if let Some(func) = func {
// Add the loop variables
let orig_scope_len = scope.len();
let counter_index = if let Some(Ident { name, .. }) = counter {
let counter_index = counter.as_ref().map(|Ident { name, .. }| {
scope.push(unsafe_cast_var_name_to_lifetime(name), 0 as INT);
Some(scope.len() - 1)
} else {
None
};
scope.len() - 1
});
scope.push(unsafe_cast_var_name_to_lifetime(name), ());
let index = scope.len() - 1;
state.scope_level += 1;