mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Shift by KEY_SIZE instead of something larger.
Currently all Gecko and Servo do the KEY_SHIFT thing, but there's no reason we need to follow that here. See https://bugzilla.mozilla.org/show_bug.cgi?id=1371949#c10 MozReview-Commit-ID: CqNi7r9e5s0
This commit is contained in:
parent
8085a37178
commit
cf982d17b9
1 changed files with 5 additions and 2 deletions
|
@ -7,10 +7,13 @@
|
||||||
use fnv::FnvHasher;
|
use fnv::FnvHasher;
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
|
|
||||||
|
// The top 12 bits of the 32-bit hash value are not used by the bloom filter.
|
||||||
|
// Consumers may rely on this to pack hashes more efficiently.
|
||||||
|
pub const BLOOM_HASH_MASK: u32 = 0x00ffffff;
|
||||||
const KEY_SIZE: usize = 12;
|
const KEY_SIZE: usize = 12;
|
||||||
|
|
||||||
const ARRAY_SIZE: usize = 1 << KEY_SIZE;
|
const ARRAY_SIZE: usize = 1 << KEY_SIZE;
|
||||||
const KEY_MASK: u32 = (1 << KEY_SIZE) - 1;
|
const KEY_MASK: u32 = (1 << KEY_SIZE) - 1;
|
||||||
const KEY_SHIFT: usize = 16;
|
|
||||||
|
|
||||||
/// A counting Bloom filter with 8-bit counters. For now we assume
|
/// A counting Bloom filter with 8-bit counters. For now we assume
|
||||||
/// that having two hash functions is enough, but we may revisit that
|
/// that having two hash functions is enough, but we may revisit that
|
||||||
|
@ -183,7 +186,7 @@ fn hash1(hash: u32) -> u32 {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn hash2(hash: u32) -> u32 {
|
fn hash2(hash: u32) -> u32 {
|
||||||
(hash >> KEY_SHIFT) & KEY_MASK
|
(hash >> KEY_SIZE) & KEY_MASK
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue