Avoid copying property name for map property access.

This commit is contained in:
Stephen Chung
2020-07-21 20:59:12 +08:00
parent ec3074106e
commit e6c3f8134d
3 changed files with 19 additions and 29 deletions

View File

@@ -400,7 +400,7 @@ fn optimize_expr(expr: Expr, state: &mut State) -> Expr {
// All other items can be thrown away.
state.set_dirty();
let pos = m.1;
m.0.into_iter().find(|((name, _), _)| name.as_str() == prop)
m.0.into_iter().find(|((name, _), _)| name.as_str() == prop.as_str())
.map(|(_, expr)| expr.set_position(pos))
.unwrap_or_else(|| Expr::Unit(pos))
}