Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 1696148

Browse files
Merge into larger interval set
This reduces the work done while merging rows. In at least one case (issue 50450), we have thousands of union([range], [20,000 ranges]), which previously inserted each of the 20,000 ranges one by one. Now we only insert one range into the right hand set after copying the set over.
1 parent 665d2c6 commit 1696148

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

compiler/rustc_index/src/interval.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,12 @@ impl<I: Idx> IntervalSet<I> {
236236
I: Step,
237237
{
238238
assert_eq!(self.domain, other.domain);
239+
if self.map.len() < other.map.len() {
240+
let backup = self.clone();
241+
self.map.clone_from(&other.map);
242+
return self.union(&backup);
243+
}
244+
239245
let mut did_insert = false;
240246
for range in other.iter_intervals() {
241247
did_insert |= self.insert_range(range);

0 commit comments

Comments
 (0)