Skip to content

Commit c05b23a

Browse files
committed
Remove an allocation
1 parent 910cb0d commit c05b23a

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

‎zjit/src/hir.rs‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6727,27 +6727,28 @@ impl Function {
67276727

67286728
loop {
67296729
for (rpo_index, &block_id) in rpo.iter().enumerate() {
6730-
let mut block_cache: HashMap<Key, InsnId> = HashMap::new();
67316730
// Set block_cache equal to the intersection of cached insns of all predecessors
67326731
// Additionally, check for back edges
6733-
match cfi.predecessors(block_id) {
6734-
[] => {},
6732+
let mut block_cache: HashMap<Key, InsnId> = match cfi.predecessors(block_id) {
6733+
[] => HashMap::new(),
67356734
[head] => {
6736-
block_cache = cached_insns[*head].clone();
67376735
if rpo_order[*head] > rpo_index {
67386736
has_back_edge |= true;
67396737
}
6738+
cached_insns[*head].clone()
67406739
}
67416740
[head, tail @ ..] => {
6742-
block_cache = cached_insns[*head].clone();
6741+
let mut cache = cached_insns[*head].clone();
67436742
for pred in tail {
6744-
block_cache.retain(|key, value| cached_insns[*pred].get(key) == Some(value));
6743+
cache.retain(|key, value| cached_insns[*pred].get(key) == Some(value));
67456744
if rpo_order[*head] > rpo_index {
67466745
has_back_edge |= true;
67476746
}
67486747
}
6748+
cache
6749+
67496750
}
6750-
}
6751+
};
67516752
let old_insns = std::mem::take(&mut self.blocks[block_id].insns);
67526753
let mut new_insns = Vec::with_capacity(old_insns.len());
67536754
for insn_id in old_insns {

0 commit comments

Comments
 (0)