From 97af6aad4af3f3b9dd91fed3343f44aae4d242ba Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" Date: Wed, 29 Mar 2023 12:26:53 -0500 Subject: [PATCH] remove unused bucket map direct add/unref calls (#30942) --- bucket_map/src/bucket.rs | 16 ---------------- bucket_map/src/bucket_api.rs | 12 ------------ bucket_map/src/bucket_map.rs | 22 +--------------------- 3 files changed, 1 insertion(+), 49 deletions(-) diff --git a/bucket_map/src/bucket.rs b/bucket_map/src/bucket.rs index c11604527..505b1a79a 100644 --- a/bucket_map/src/bucket.rs +++ b/bucket_map/src/bucket.rs @@ -256,22 +256,6 @@ impl<'b, T: Clone + Copy + 'static> Bucket { Err(BucketMapError::IndexNoSpace(index.capacity_pow2)) } - pub fn addref(&mut self, key: &Pubkey) -> Option { - if let Ok((Some(elem), _)) = Self::find_index_entry_mut(&mut self.index, key, self.random) { - elem.ref_count += 1; - return Some(elem.ref_count); - } - None - } - - pub fn unref(&mut self, key: &Pubkey) -> Option { - if let Ok((Some(elem), _)) = Self::find_index_entry_mut(&mut self.index, key, self.random) { - elem.ref_count -= 1; - return Some(elem.ref_count); - } - None - } - pub fn read_value(&self, key: &Pubkey) -> Option<(&[T], RefCount)> { //debug!("READ_VALUE: {:?}", key); let (elem, _) = self.find_index_entry(key)?; diff --git a/bucket_map/src/bucket_api.rs b/bucket_map/src/bucket_api.rs index 695d6836b..c4be1cd24 100644 --- a/bucket_map/src/bucket_api.rs +++ b/bucket_map/src/bucket_api.rs @@ -98,18 +98,6 @@ impl BucketApi { bucket } - pub fn addref(&self, key: &Pubkey) -> Option { - self.get_write_bucket() - .as_mut() - .and_then(|bucket| bucket.addref(key)) - } - - pub fn unref(&self, key: &Pubkey) -> Option { - self.get_write_bucket() - .as_mut() - .and_then(|bucket| bucket.unref(key)) - } - pub fn insert(&self, pubkey: &Pubkey, value: (&[T], RefCount)) { let mut bucket = self.get_write_bucket(); bucket.as_mut().unwrap().insert(pubkey, value) diff --git a/bucket_map/src/bucket_map.rs b/bucket_map/src/bucket_map.rs index 3b7d404c4..0193642c4 100644 --- a/bucket_map/src/bucket_map.rs +++ b/bucket_map/src/bucket_map.rs @@ -158,20 +158,6 @@ impl BucketMap { 0 } } - - /// Increment the refcount for Pubkey `key` - pub fn addref(&self, key: &Pubkey) -> Option { - let ix = self.bucket_ix(key); - let bucket = &self.buckets[ix]; - bucket.addref(key) - } - - /// Decrement the refcount for Pubkey `key` - pub fn unref(&self, key: &Pubkey) -> Option { - let ix = self.bucket_ix(key); - let bucket = &self.buckets[ix]; - bucket.unref(key) - } } /// Look at the first 8 bytes of the input and reinterpret them as a u64 @@ -498,13 +484,7 @@ mod tests { rc = if inc { rc + 1 } else { rc - 1 }; hm.insert(k, (v.to_vec(), rc)); maps.iter().for_each(|map| { - if thread_rng().gen_range(0, 2) == 0 { - map.update(&k, |current| Some((current.unwrap().0.to_vec(), rc))) - } else if inc { - map.addref(&k); - } else { - map.unref(&k); - } + map.update(&k, |current| Some((current.unwrap().0.to_vec(), rc))) }); return_key(k);