From 9ff52bf332e03b0f0d06f3a8d8a3719b7b62c475 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Mon, 13 Oct 2025 12:56:34 +1100 Subject: [PATCH] Clear `ChunkedBitSet` without reallocating --- compiler/rustc_index/src/bit_set.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_index/src/bit_set.rs b/compiler/rustc_index/src/bit_set.rs index f7649c5f5c55e..d5a184c259319 100644 --- a/compiler/rustc_index/src/bit_set.rs +++ b/compiler/rustc_index/src/bit_set.rs @@ -585,8 +585,7 @@ impl ChunkedBitSet { } pub fn clear(&mut self) { - let domain_size = self.domain_size(); - *self = ChunkedBitSet::new_empty(domain_size); + self.chunks.fill_with(|| Chunk::Zeros); } #[cfg(test)] @@ -684,9 +683,7 @@ impl ChunkedBitSet { /// Sets all bits to true. pub fn insert_all(&mut self) { - for chunk in self.chunks.iter_mut() { - *chunk = Ones; - } + self.chunks.fill_with(|| Chunk::Ones); } /// Returns `true` if the set has changed.