File tree 1 file changed +14
-4
lines changed
src/librustc_data_structures
1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -557,10 +557,20 @@ impl<T: Idx> HybridBitSet<T> {
557
557
changed
558
558
}
559
559
HybridBitSet :: Dense ( other_dense) => {
560
- // `self` is sparse and `other` is dense. Clone the
561
- // other set and do the bitwise union with sparse
562
- // `self`. This avoids traversing the dense
563
- // representation twice.
560
+ // `self` is sparse and `other` is dense. To
561
+ // merge them, we have two available strategies:
562
+ // * Densify `self` then merge other
563
+ // * Clone other then integrate bits from `self`
564
+ // The second strategy requires dedicated method
565
+ // since the usual `union` returns the wrong
566
+ // result. In the dedicated case the computation
567
+ // is slightly faster if the bits of the sparse
568
+ // bitset map to only few words of the dense
569
+ // representation, i.e. indices are near each
570
+ // other.
571
+ //
572
+ // Benchmarking seems to suggest that the second
573
+ // option is worth it.
564
574
let mut new_dense = other_dense. clone ( ) ;
565
575
let changed = new_dense. reverse_union_sparse ( self_sparse) ;
566
576
* self = HybridBitSet :: Dense ( new_dense) ;
You can’t perform that action at this time.
0 commit comments