mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-22 02:00:00 +03:00
Auto merge of #25095 - huonw:faster-bitvec, r=alexcrichton
This makes the `bit::vec::bench::bench_bit_vec_big_union` benchmark go from `774 ns/iter (+/- 190)` to `602 ns/iter (+/- 5)`. (There's room for more work here too: if one can guarantee 128-bit alignment for the vector, the compiler actually optimises `union`, `intersection` etc. to SIMD instructions, which end up being ~5x faster that the original version, and 4x faster than the optimised version in this patch.)
This commit is contained in:
@@ -210,15 +210,13 @@ fn process<F>(&mut self, other: &BitVec, mut op: F) -> bool where F: FnMut(u32,
|
||||
assert_eq!(self.len(), other.len());
|
||||
// This could theoretically be a `debug_assert!`.
|
||||
assert_eq!(self.storage.len(), other.storage.len());
|
||||
let mut changed = false;
|
||||
let mut changed_bits = 0;
|
||||
for (a, b) in self.blocks_mut().zip(other.blocks()) {
|
||||
let w = op(*a, b);
|
||||
if *a != w {
|
||||
changed = true;
|
||||
*a = w;
|
||||
}
|
||||
changed_bits |= *a ^ w;
|
||||
*a = w;
|
||||
}
|
||||
changed
|
||||
changed_bits != 0
|
||||
}
|
||||
|
||||
/// Iterator over mutable refs to the underlying blocks of data.
|
||||
|
||||
Reference in New Issue
Block a user