File tree 1 file changed +3
-14
lines changed
1 file changed +3
-14
lines changed Original file line number Diff line number Diff line change @@ -25,13 +25,13 @@ impl BloomFilter {
25
25
26
26
#[ inline]
27
27
fn insert_hash ( & mut self , hash : u64 ) {
28
- self . 0 |= 1 << ( hash1 ( hash) % 64 ) ;
29
- self . 0 |= 1 << ( hash2 ( hash) % 64 ) ;
28
+ self . 0 |= ( 1u64 << ( hash & 63 ) ) | ( 1u64 << ( ( hash >> KEY_SIZE ) & 63 ) ) ;
30
29
}
31
30
32
31
#[ inline]
33
32
fn might_contain_hash ( self , hash : u64 ) -> bool {
34
- self . 0 & ( 1 << ( hash1 ( hash) % 64 ) ) != 0 && self . 0 & ( 1 << ( hash2 ( hash) % 64 ) ) != 0
33
+ let bits = ( 1u64 << ( hash & 63 ) ) | ( 1u64 << ( ( hash >> KEY_SIZE ) & 63 ) ) ;
34
+ ( self . 0 & bits) == bits
35
35
}
36
36
37
37
/// Check whether this element MAY have the given class.
@@ -45,17 +45,6 @@ impl BloomFilter {
45
45
}
46
46
47
47
const KEY_SIZE : usize = 32 ;
48
- const KEY_MASK : u64 = u32:: MAX as u64 ;
49
-
50
- #[ inline]
51
- fn hash1 ( hash : u64 ) -> u64 {
52
- hash & KEY_MASK
53
- }
54
-
55
- #[ inline]
56
- fn hash2 ( hash : u64 ) -> u64 {
57
- ( hash >> KEY_SIZE ) & KEY_MASK
58
- }
59
48
60
49
#[ derive( Debug ) ]
61
50
pub ( crate ) enum Cache {
You can’t perform that action at this time.
0 commit comments