Skip to content

Commit 9ff52bf

Browse files
committed
Clear ChunkedBitSet without reallocating
1 parent 2300c2a commit 9ff52bf

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

compiler/rustc_index/src/bit_set.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,7 @@ impl<T: Idx> ChunkedBitSet<T> {
585585
}
586586

587587
pub fn clear(&mut self) {
588-
let domain_size = self.domain_size();
589-
*self = ChunkedBitSet::new_empty(domain_size);
588+
self.chunks.fill_with(|| Chunk::Zeros);
590589
}
591590

592591
#[cfg(test)]
@@ -684,9 +683,7 @@ impl<T: Idx> ChunkedBitSet<T> {
684683

685684
/// Sets all bits to true.
686685
pub fn insert_all(&mut self) {
687-
for chunk in self.chunks.iter_mut() {
688-
*chunk = Ones;
689-
}
686+
self.chunks.fill_with(|| Chunk::Ones);
690687
}
691688

692689
/// Returns `true` if the set has changed.

0 commit comments

Comments
 (0)