Use iterators.

This commit is contained in:
Stephen Chung
2023-01-31 19:44:46 +08:00
parent faa48f78c3
commit ca02d46a49
2 changed files with 39 additions and 33 deletions

View File

@@ -1244,14 +1244,14 @@ impl Engine {
if !has_condition && ranges.is_empty() && r.len() <= SMALL_SWITCH_RANGE
{
// Unroll small range
for n in r {
r.into_iter().for_each(|n| {
let hasher = &mut get_hasher();
Dynamic::from_int(n).hash(hasher);
cases
.entry(hasher.finish())
.and_modify(|cases| cases.push(index))
.or_insert_with(|| [index].into());
}
});
} else {
// Other range
r.set_index(index);
@@ -3983,9 +3983,9 @@ impl Engine {
{
let mut m = crate::Module::new();
for fn_def in _lib {
_lib.into_iter().for_each(|fn_def| {
m.set_script_fn(fn_def);
}
});
return Ok(AST::new(statements, m));
}