This commit is contained in:
2018-09-10 21:14:02 +02:00
parent 60daedad0c
commit 4ad311e389
2 changed files with 7 additions and 7 deletions

View File

@@ -21,7 +21,7 @@ fn contains(data: &[u64]) {
let set = BitSet::new(); let set = BitSet::new();
for v in data { for v in data {
set.contains(v); set.contains(*v);
} }
} }

View File

@@ -25,7 +25,7 @@ type Storage = HashMap<u64, Block, BitBuildHasher>;
pub type BitHashMap<V> = HashMap<u64, V, BitBuildHasher>; pub type BitHashMap<V> = HashMap<u64, V, BitBuildHasher>;
#[inline] #[inline]
fn block_bit(x: &u64, d: &u64) -> (u64, u64) { fn block_bit(x: u64, d: u64) -> (u64, u64) {
(x / d, x % d) (x / d, x % d)
} }
@@ -91,8 +91,8 @@ impl BitSet {
} }
#[inline] #[inline]
pub fn contains(&self, value: &u64) -> bool { pub fn contains(&self, value: u64) -> bool {
let (block, bit) = block_bit(value, &BITS); let (block, bit) = block_bit(value, BITS);
match self.blocks.get(&block) { match self.blocks.get(&block) {
Some(block) => (block & (1 << bit)) != 0, Some(block) => (block & (1 << bit)) != 0,
@@ -121,7 +121,7 @@ impl BitSet {
#[inline] #[inline]
pub fn insert(&mut self, value: u64) -> bool { pub fn insert(&mut self, value: u64) -> bool {
let (block, bit) = block_bit(&value, &BITS); let (block, bit) = block_bit(value, BITS);
let block = self.blocks.entry(block).or_insert(0); let block = self.blocks.entry(block).or_insert(0);
let n = 1 << bit; let n = 1 << bit;
@@ -137,8 +137,8 @@ impl BitSet {
} }
#[inline] #[inline]
pub fn remove(&mut self, value: &u64) -> bool { pub fn remove(&mut self, value: u64) -> bool {
let (block, bit) = block_bit(value, &BITS); let (block, bit) = block_bit(value, BITS);
let block = self.blocks.entry(block).or_insert(0); let block = self.blocks.entry(block).or_insert(0);
let n = 1 << bit; let n = 1 << bit;