From 8260478a87b805c3d65dc1c9e76a744b81396ef2 Mon Sep 17 00:00:00 2001 From: Ali Behjati Date: Wed, 18 Oct 2023 15:00:37 +0200 Subject: [PATCH] Update hermes/src/aggregate/metrics.rs Co-authored-by: Reisen --- hermes/src/aggregate/metrics.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/hermes/src/aggregate/metrics.rs b/hermes/src/aggregate/metrics.rs index 11f63e9fb..f8fb2c47b 100644 --- a/hermes/src/aggregate/metrics.rs +++ b/hermes/src/aggregate/metrics.rs @@ -86,16 +86,12 @@ impl Metrics { /// Observe a slot and event. An event at a slot should be observed only once. pub fn observe(&mut self, slot: Slot, event: Event) { - let order = if let Some(newest_observed_slot) = self.newest_observed_slot.get(&event) { - if slot > *newest_observed_slot { - self.newest_observed_slot.insert(event.clone(), slot); - SlotOrder::New - } else { - SlotOrder::OutOfOrder - } - } else { + let order = if self.newest_observed_slot.get(&event) + .map_or(true, |&observed_slot| slot > observed_slot) { self.newest_observed_slot.insert(event.clone(), slot); SlotOrder::New + } else { + SlotOrder::OutOfOrder };