Skip to content

Commit

Permalink
vm-monitor: Replace filter_map with filter
Browse files Browse the repository at this point in the history
I think there's a clippy lint for this? Not sure if we're not using
that, or something.

In any case, I was confused reading this code previously, and I think
this change should make what's going on a bit clearer (because `high`
wasn't changing anyways!).
  • Loading branch information
sharnoff committed Oct 3, 2023
1 parent 00369c8 commit 8e1c994
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions libs/vm_monitor/src/cgroup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,8 @@ impl CgroupWatcher {
}
})
// Only report the event if the memory.high count increased
.filter_map(|high| {
if MEMORY_EVENT_COUNT.fetch_max(high, Ordering::AcqRel) < high {
Some(high)
} else {
None
}
})
// NB: fetch_max sets the atomic to the max, but *returns* the previous value.
.filter(|&high| MEMORY_EVENT_COUNT.fetch_max(high, Ordering::AcqRel) < high)
.map(Sequenced::new);

let initial_count = get_event_count(
Expand Down

0 comments on commit 8e1c994

Please sign in to comment.