Refactors RollingBitField::min() (#33911)

This commit is contained in:
Brooks 2023-10-28 12:47:29 -04:00 committed by GitHub
parent b0bf24b6fc
commit cdc284189a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 7 deletions

View File

@ -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)
}
}