mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-13 15:58:18 +02:00
compiler/rust/bitset: Don't reserve space in remove()
If the requested bit is past the end of the set, we can just return false. We don't have to grow the bitset. Reviewed-by: Mel Henning <mhenning@darkrefraction.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41915>
This commit is contained in:
parent
81c9eddb69
commit
ffe6cdd52d
1 changed files with 7 additions and 4 deletions
|
|
@ -181,10 +181,13 @@ impl<K: IntoBitIndex> BitSet<K> {
|
|||
|
||||
pub fn remove(&mut self, key: K) -> bool {
|
||||
let idx = BitIndex::from(key);
|
||||
self.reserve_words(idx.word + 1);
|
||||
let exists = self.words[idx.word] & (1_u32 << idx.bit) != 0;
|
||||
self.words[idx.word] &= !(1_u32 << idx.bit);
|
||||
exists
|
||||
if idx.word < self.words.len() {
|
||||
let exists = self.words[idx.word] & (1_u32 << idx.bit) != 0;
|
||||
self.words[idx.word] &= !(1_u32 << idx.bit);
|
||||
exists
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue