Skip to content

Commit 454cd01

Browse files
authored
Recompute priority only once during init (#238)
While queueing bundles, I noticed that we compute the priority of the bundle (i.e., the number of instructions) twice: once directly in `Env::queue_bundles` and again within `Env::recompute_bundle_properties`. This change removes the first instance, saving some small amount of time iterating over the bundle's ranges.
1 parent 2ead347 commit 454cd01

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/ion/merge.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ impl<'a, F: Function> Env<'a, F> {
379379
for entry in &self.bundles[bundle].ranges {
380380
total += entry.range.len() as u32;
381381
}
382+
trace!(" -> prio {total}");
382383
total
383384
}
384385

@@ -390,12 +391,9 @@ impl<'a, F: Function> Env<'a, F> {
390391
trace!(" -> no ranges; skipping");
391392
continue;
392393
}
393-
let prio = self.compute_bundle_prio(bundle);
394-
trace!(" -> prio {}", prio);
395-
self.bundles[bundle].prio = prio;
396394
self.recompute_bundle_properties(bundle);
397-
self.allocation_queue
398-
.insert(bundle, prio as usize, PReg::invalid());
395+
let prio = self.bundles[bundle].prio as usize;
396+
self.allocation_queue.insert(bundle, prio, PReg::invalid());
399397
}
400398
self.output.stats.merged_bundle_count = self.allocation_queue.heap.len();
401399
}

0 commit comments

Comments
 (0)