Run codemod --extensions rs Hash::new_rand solana_sdk:#️⃣:new_rand
This commit is contained in:
@@ -102,7 +102,7 @@ fn bench_sigs_hashmap(bencher: &mut Bencher) {
|
||||
#[bench]
|
||||
fn bench_add_hash(bencher: &mut Bencher) {
|
||||
let mut rng = rand::thread_rng();
|
||||
let hash_values: Vec<_> = std::iter::repeat_with(|| Hash::new_rand(&mut rng))
|
||||
let hash_values: Vec<_> = std::iter::repeat_with(|| solana_sdk::hash::new_rand(&mut rng))
|
||||
.take(1200)
|
||||
.collect();
|
||||
let mut fail = 0;
|
||||
@@ -122,7 +122,7 @@ fn bench_add_hash(bencher: &mut Bencher) {
|
||||
#[bench]
|
||||
fn bench_add_hash_atomic(bencher: &mut Bencher) {
|
||||
let mut rng = rand::thread_rng();
|
||||
let hash_values: Vec<_> = std::iter::repeat_with(|| Hash::new_rand(&mut rng))
|
||||
let hash_values: Vec<_> = std::iter::repeat_with(|| solana_sdk::hash::new_rand(&mut rng))
|
||||
.take(1200)
|
||||
.collect();
|
||||
let mut fail = 0;
|
||||
|
@@ -264,7 +264,7 @@ mod test {
|
||||
#[test]
|
||||
fn test_atomic_bloom() {
|
||||
let mut rng = rand::thread_rng();
|
||||
let hash_values: Vec<_> = std::iter::repeat_with(|| Hash::new_rand(&mut rng))
|
||||
let hash_values: Vec<_> = std::iter::repeat_with(|| solana_sdk::hash::new_rand(&mut rng))
|
||||
.take(1200)
|
||||
.collect();
|
||||
let bloom: AtomicBloom<_> = Bloom::<Hash>::random(1287, 0.1, 7424).into();
|
||||
@@ -279,7 +279,7 @@ mod test {
|
||||
for hash_value in hash_values {
|
||||
assert!(bloom.contains(&hash_value));
|
||||
}
|
||||
let false_positive = std::iter::repeat_with(|| Hash::new_rand(&mut rng))
|
||||
let false_positive = std::iter::repeat_with(|| solana_sdk::hash::new_rand(&mut rng))
|
||||
.take(10_000)
|
||||
.filter(|hash_value| bloom.contains(hash_value))
|
||||
.count();
|
||||
@@ -291,7 +291,7 @@ mod test {
|
||||
let mut rng = rand::thread_rng();
|
||||
let keys: Vec<_> = std::iter::repeat_with(|| rng.gen()).take(5).collect();
|
||||
let mut bloom = Bloom::<Hash>::new(9731, keys.clone());
|
||||
let hash_values: Vec<_> = std::iter::repeat_with(|| Hash::new_rand(&mut rng))
|
||||
let hash_values: Vec<_> = std::iter::repeat_with(|| solana_sdk::hash::new_rand(&mut rng))
|
||||
.take(1000)
|
||||
.collect();
|
||||
for hash_value in &hash_values {
|
||||
@@ -318,7 +318,7 @@ mod test {
|
||||
assert!(bloom.contains(hash_value));
|
||||
}
|
||||
// Round trip, inserting new hash values.
|
||||
let more_hash_values: Vec<_> = std::iter::repeat_with(|| Hash::new_rand(&mut rng))
|
||||
let more_hash_values: Vec<_> = std::iter::repeat_with(|| solana_sdk::hash::new_rand(&mut rng))
|
||||
.take(1000)
|
||||
.collect();
|
||||
let bloom: AtomicBloom<_> = bloom.into();
|
||||
@@ -339,7 +339,7 @@ mod test {
|
||||
for hash_value in &more_hash_values {
|
||||
assert!(bloom.contains(hash_value));
|
||||
}
|
||||
let false_positive = std::iter::repeat_with(|| Hash::new_rand(&mut rng))
|
||||
let false_positive = std::iter::repeat_with(|| solana_sdk::hash::new_rand(&mut rng))
|
||||
.take(10_000)
|
||||
.filter(|hash_value| bloom.contains(hash_value))
|
||||
.count();
|
||||
|
Reference in New Issue
Block a user