Skip to content

Commit

Permalink
Refactors RollingBitField::min() (#33911)
Browse files Browse the repository at this point in the history
  • Loading branch information
brooksprumo authored Oct 28, 2023
1 parent b0bf24b commit cdc2841
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions accounts-db/src/rolling_bit_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,12 @@ impl RollingBitField {
} else if self.excess.is_empty() {
Some(self.min)
} else {
let mut min = if self.all_items_in_excess() {
u64::MAX
let excess_min = self.excess.iter().min().copied();
if self.all_items_in_excess() {
excess_min
} else {
self.min
};
for item in &self.excess {
min = std::cmp::min(min, *item);
Some(std::cmp::min(self.min, excess_min.unwrap_or(u64::MAX)))
}
Some(min)
}
}

Expand Down

0 comments on commit cdc2841

Please sign in to comment.