From cdc284189a042b7a4e2c44b99c2bc36da7566524 Mon Sep 17 00:00:00 2001 From: Brooks Date: Sat, 28 Oct 2023 12:47:29 -0400 Subject: [PATCH] Refactors RollingBitField::min() (#33911) --- accounts-db/src/rolling_bit_field.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/accounts-db/src/rolling_bit_field.rs b/accounts-db/src/rolling_bit_field.rs index cfbfe820a176c7..65d3ff76b54ae7 100644 --- a/accounts-db/src/rolling_bit_field.rs +++ b/accounts-db/src/rolling_bit_field.rs @@ -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) } }