File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,13 +25,13 @@ impl BloomFilter {
2525
2626 #[ inline]
2727 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 ) ) ;
3029 }
3130
3231 #[ inline]
3332 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
3535 }
3636
3737 /// Check whether this element MAY have the given class.
@@ -45,17 +45,6 @@ impl BloomFilter {
4545}
4646
4747const 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- }
5948
6049#[ derive( Debug ) ]
6150pub ( crate ) enum Cache {
You can’t perform that action at this time.
0 commit comments