Some micro-optimizations in BitVec.
This commit is contained in:
@@ -83,14 +83,16 @@ impl BitVec {
|
|||||||
let last_idx = other.bits.len() - 1;
|
let last_idx = other.bits.len() - 1;
|
||||||
self.ensure_idx(last_idx);
|
self.ensure_idx(last_idx);
|
||||||
|
|
||||||
let mut changed = false;
|
let mut changed = 0;
|
||||||
for (self_word, other_word) in self.bits.iter_mut().zip(other.bits.iter()) {
|
for (self_word, other_word) in self.bits.iter_mut().zip(other.bits.iter()) {
|
||||||
if *other_word & !*self_word != 0 {
|
if *other_word == 0 {
|
||||||
changed = true;
|
// Avoid cache misses in `self` if `other` is zeroes.
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
changed |= *other_word & !*self_word;
|
||||||
*self_word |= *other_word;
|
*self_word |= *other_word;
|
||||||
}
|
}
|
||||||
changed
|
changed != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn and(&mut self, other: &Self) {
|
pub fn and(&mut self, other: &Self) {
|
||||||
|
|||||||
Reference in New Issue
Block a user