use Arc::clone() instead
This commit is contained in:
committed by
Jeff Washington (jwash)
parent
6af722f2ae
commit
b538ff8b27
@ -33,11 +33,11 @@ impl<T: Clone + Copy> Bucket<T> {
|
|||||||
stats: Arc<BucketMapStats>,
|
stats: Arc<BucketMapStats>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let index = DataBucket::new(
|
let index = DataBucket::new(
|
||||||
drives.clone(),
|
Arc::clone(&drives),
|
||||||
1,
|
1,
|
||||||
std::mem::size_of::<IndexEntry>() as u64,
|
std::mem::size_of::<IndexEntry>() as u64,
|
||||||
max_search,
|
max_search,
|
||||||
stats.index.clone(),
|
Arc::clone(&stats.index),
|
||||||
);
|
);
|
||||||
Self {
|
Self {
|
||||||
random: thread_rng().gen(),
|
random: thread_rng().gen(),
|
||||||
@ -296,12 +296,12 @@ impl<T: Clone + Copy> Bucket<T> {
|
|||||||
//likelyhood of a re-index collision of 2^(max_search)^2
|
//likelyhood of a re-index collision of 2^(max_search)^2
|
||||||
//1 in 2^32
|
//1 in 2^32
|
||||||
let index = DataBucket::new_with_capacity(
|
let index = DataBucket::new_with_capacity(
|
||||||
self.drives.clone(),
|
Arc::clone(&self.drives),
|
||||||
1,
|
1,
|
||||||
std::mem::size_of::<IndexEntry>() as u64,
|
std::mem::size_of::<IndexEntry>() as u64,
|
||||||
self.index.capacity + i, // * 2,
|
self.index.capacity + i, // * 2,
|
||||||
self.index.max_search,
|
self.index.max_search,
|
||||||
self.stats.index.clone(),
|
Arc::clone(&self.stats.index),
|
||||||
);
|
);
|
||||||
let random = thread_rng().gen();
|
let random = thread_rng().gen();
|
||||||
let mut valid = true;
|
let mut valid = true;
|
||||||
@ -352,11 +352,11 @@ impl<T: Clone + Copy> Bucket<T> {
|
|||||||
if self.data.get(sz.0 as usize).is_none() {
|
if self.data.get(sz.0 as usize).is_none() {
|
||||||
for i in self.data.len() as u64..(sz.0 + 1) {
|
for i in self.data.len() as u64..(sz.0 + 1) {
|
||||||
self.data.push(DataBucket::new(
|
self.data.push(DataBucket::new(
|
||||||
self.drives.clone(),
|
Arc::clone(&self.drives),
|
||||||
1 << i,
|
1 << i,
|
||||||
std::mem::size_of::<T>() as u64,
|
std::mem::size_of::<T>() as u64,
|
||||||
self.index.max_search,
|
self.index.max_search,
|
||||||
self.stats.data.clone(),
|
Arc::clone(&self.stats.data),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,9 +162,9 @@ impl<T: Clone + Copy + Debug> BucketMap<T> {
|
|||||||
let mut bucket = self.buckets[ix].write().unwrap();
|
let mut bucket = self.buckets[ix].write().unwrap();
|
||||||
if bucket.is_none() {
|
if bucket.is_none() {
|
||||||
*bucket = Some(Bucket::new(
|
*bucket = Some(Bucket::new(
|
||||||
self.drives.clone(),
|
Arc::clone(&self.drives),
|
||||||
self.max_search,
|
self.max_search,
|
||||||
self.stats.clone(),
|
Arc::clone(&self.stats),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
let bucket = bucket.as_mut().unwrap();
|
let bucket = bucket.as_mut().unwrap();
|
||||||
|
Reference in New Issue
Block a user