Fix clippy::perf lint errors

This commit is contained in:
J Henry Waugh 2020-09-20 13:07:43 -05:00
parent 788a22108b
commit c8dffff515
3 changed files with 4 additions and 6 deletions

View File

@ -1168,7 +1168,7 @@ impl Engine {
.take_immutable_string() .take_immutable_string()
.map_err(|_| EvalAltResult::ErrorStringIndexExpr(idx_pos))?; .map_err(|_| EvalAltResult::ErrorStringIndexExpr(idx_pos))?;
map.entry(index).or_insert(Default::default()).into() map.entry(index).or_insert_with(Default::default).into()
} else { } else {
let index = idx let index = idx
.read_lock::<ImmutableString>() .read_lock::<ImmutableString>()
@ -2014,6 +2014,6 @@ impl Engine {
self.type_names self.type_names
.as_ref() .as_ref()
.and_then(|t| t.get(name).map(String::as_str)) .and_then(|t| t.get(name).map(String::as_str))
.unwrap_or(map_std_type_name(name)) .unwrap_or_else(|| map_std_type_name(name))
} }
} }

View File

@ -46,9 +46,7 @@ mod map_functions {
} }
pub fn fill_with(map1: &mut Map, map2: Map) { pub fn fill_with(map1: &mut Map, map2: Map) {
map2.into_iter().for_each(|(key, value)| { map2.into_iter().for_each(|(key, value)| {
if !map1.contains_key(&key) { map1.entry(key).or_insert(value);
map1.insert(key, value);
}
}); });
} }

View File

@ -3479,7 +3479,7 @@ pub fn map_dynamic_to_expr(value: Dynamic, pos: Position) -> Option<Expr> {
Union::Unit(_) => Some(Expr::Unit(pos)), Union::Unit(_) => Some(Expr::Unit(pos)),
Union::Int(value) => Some(Expr::IntegerConstant(Box::new((value, pos)))), Union::Int(value) => Some(Expr::IntegerConstant(Box::new((value, pos)))),
Union::Char(value) => Some(Expr::CharConstant(Box::new((value, pos)))), Union::Char(value) => Some(Expr::CharConstant(Box::new((value, pos)))),
Union::Str(value) => Some(Expr::StringConstant(Box::new((value.clone(), pos)))), Union::Str(value) => Some(Expr::StringConstant(Box::new((value, pos)))),
Union::Bool(true) => Some(Expr::True(pos)), Union::Bool(true) => Some(Expr::True(pos)),
Union::Bool(false) => Some(Expr::False(pos)), Union::Bool(false) => Some(Expr::False(pos)),
#[cfg(not(feature = "no_index"))] #[cfg(not(feature = "no_index"))]