aboutsummaryrefslogtreecommitdiffstats
path: root/components/selectors/bloom.rs
diff options
context:
space:
mode:
authorBobby Holley <bobbyholley@gmail.com>2017-06-21 16:56:59 -0700
committerBobby Holley <bobbyholley@gmail.com>2017-06-21 19:53:16 -0700
commit71e76a054d20221e9782cebb12091a81a48fcf4c (patch)
treeae9bbf99abe71a82590606e78d838cd0a02c7a04 /components/selectors/bloom.rs
parent28c35ac9dfb3063ba7e38514d1bf4ce8b0196dcb (diff)
downloadservo-71e76a054d20221e9782cebb12091a81a48fcf4c.tar.gz
servo-71e76a054d20221e9782cebb12091a81a48fcf4c.zip
Be smarter when clearing the bloom filter.
Diffstat (limited to 'components/selectors/bloom.rs')
-rw-r--r--components/selectors/bloom.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/components/selectors/bloom.rs b/components/selectors/bloom.rs
index 083907d37e6..8caab9935cb 100644
--- a/components/selectors/bloom.rs
+++ b/components/selectors/bloom.rs
@@ -108,6 +108,18 @@ impl BloomFilter {
self.counters = [0; ARRAY_SIZE]
}
+ // Slow linear accessor to make sure the bloom filter is zeroed. This should
+ // never be used in release builds.
+ #[cfg(debug_assertions)]
+ pub fn is_zeroed(&self) -> bool {
+ self.counters.iter().all(|x| *x == 0)
+ }
+
+ #[cfg(not(debug_assertions))]
+ pub fn is_zeroed(&self) -> bool {
+ unreachable!()
+ }
+
#[inline]
pub fn insert_hash(&mut self, hash: u32) {
{