Performance boost?

This commit is contained in:
2018-01-19 15:52:04 +01:00
parent 9fbf57ab4c
commit 3367a178b8

View File

@@ -253,10 +253,14 @@ impl<'a> ops::Sub<&'a BitSet> for &'a BitSet {
fn sub(self, rhs: &'a BitSet) -> BitSet {
let mut set = self.clone();
for (key, value) in &rhs.blocks {
let block = set.blocks.entry(*key).or_insert(0);
for (key, block) in &mut set.blocks {
if let Some(value) = rhs.blocks.get(&key) {
// let n = block.count_ones();
*block &= !value;
// set.nbits += (block.count_ones() - n) as usize;
}
}
set.nbits = set.blocks.values().map(|block| block.count_ones()).sum::<u32>() as usize;