Run `codemod --extensions rs Hash::new_rand solana_sdk:#️⃣:new_rand`

This commit is contained in:
Michael Vines 2020-10-19 12:15:55 -07:00
parent 7bc073defe
commit 17c391121a
4 changed files with 13 additions and 13 deletions

View File

@ -14,7 +14,7 @@ use test::Bencher;
#[bench]
fn bench_hash_as_u64(bencher: &mut Bencher) {
let mut rng = thread_rng();
let hashes: Vec<_> = std::iter::repeat_with(|| Hash::new_rand(&mut rng))
let hashes: Vec<_> = std::iter::repeat_with(|| solana_sdk::hash::new_rand(&mut rng))
.take(1000)
.collect();
bencher.iter(|| {
@ -34,7 +34,7 @@ fn bench_build_crds_filters(bencher: &mut Bencher) {
for _ in 0..50_000 {
crds_gossip_pull
.purged_values
.push_back((Hash::new_rand(&mut rng), rng.gen()));
.push_back((solana_sdk::hash::new_rand(&mut rng), rng.gen()));
}
let mut num_inserts = 0;
for _ in 0..90_000 {

View File

@ -626,7 +626,7 @@ mod test {
}
let mut rng = thread_rng();
for _ in 0..100 {
let hash = Hash::new_rand(&mut rng);
let hash = solana_sdk::hash::new_rand(&mut rng);
assert_eq!(CrdsFilter::hash_as_u64(&hash), hash_as_u64_bitops(&hash));
}
}
@ -638,7 +638,7 @@ mod test {
assert_eq!(filter.mask, mask);
let mut rng = thread_rng();
for _ in 0..10 {
let hash = Hash::new_rand(&mut rng);
let hash = solana_sdk::hash::new_rand(&mut rng);
assert!(filter.test_mask(&hash));
}
}
@ -797,7 +797,7 @@ mod test {
let mut rng = thread_rng();
let crds_filter_set =
CrdsFilterSet::new(/*num_items=*/ 9672788, /*max_bytes=*/ 8196);
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(1024)
.collect();
for hash_value in &hash_values {
@ -849,7 +849,7 @@ mod test {
for _ in 0..10_000 {
crds_gossip_pull
.purged_values
.push_back((Hash::new_rand(&mut rng), rng.gen()));
.push_back((solana_sdk::hash::new_rand(&mut rng), rng.gen()));
}
let mut num_inserts = 0;
for _ in 0..20_000 {

View File

@ -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;

View File

@ -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();