Skip to content

Commit

Permalink
WIP replace an iter with filter approach with for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
raftedproc committed Jun 17, 2024
1 parent bcdc399 commit e13b5b2
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions air/src/execution_step/instructions/fold/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,23 +110,17 @@ pub(crate) fn create_canon_stream_map_iterable_value(
// Can not create iterable from existing CanonStreamMap b/c CSM contains a map with
// a limited lifetime but the boxed value needs static lifetime.
let mut met_keys = HashSet::new();
let values = canon_stream_map
.iter()
.rev()
.filter(|&val| {
if let Some(map_key) = StreamMapKey::from_kvpair_owned(val) {
if met_keys.get(&map_key).is_some() {
false
} else {
met_keys.insert(map_key);
true
}
} else {
false
let mut values = vec![];

for val in canon_stream_map.canon_stream_map.iter().rev() {
if let Some(map_key) = StreamMapKey::from_kvpair_owned(val) {
if met_keys.get(&map_key).is_none() {
met_keys.insert(map_key);
values.push(val.clone());
}
})
.cloned()
.collect::<Vec<_>>();
}
}

let iterable_ingredients = CanonStreamMapIterableIngredients::init(values);
let iterable = Box::new(iterable_ingredients);
Ok(FoldIterableScalar::ScalarBased(iterable))
Expand Down

0 comments on commit e13b5b2

Please sign in to comment.