Remove folds (#10128)

automerge
This commit is contained in:
Greg Fitzgerald
2020-05-19 19:13:41 -06:00
committed by GitHub
parent 439fd30840
commit d9919b99d2
7 changed files with 52 additions and 54 deletions

View File

@ -3,7 +3,6 @@
use byteorder::{ByteOrder, LittleEndian};
use solana_sdk::clock::Slot;
use std::ops::Add;
#[derive(Default, Clone, Deserialize, Serialize)]
pub struct HardForks {
@ -34,16 +33,17 @@ impl HardForks {
// The expected number of hard forks in a cluster is small.
// If this turns out to be false then a more efficient data
// structure may be needed here to avoid this linear search
let fork_count = self
let fork_count: usize = self
.hard_forks
.iter()
.fold(0, |acc, (fork_slot, fork_count)| {
acc.add(if parent_slot < *fork_slot && slot >= *fork_slot {
.map(|(fork_slot, fork_count)| {
if parent_slot < *fork_slot && slot >= *fork_slot {
*fork_count
} else {
0
})
});
}
})
.sum();
if fork_count > 0 {
let mut buf = [0u8; 8];