Skip to content

Commit 215ed71

Browse files
committed
Apply code suggestions
1 parent 8b47059 commit 215ed71

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/transforms/dedupe/timed_transform.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,18 @@ impl TimedDedupe {
3333
pub fn transform_one(&mut self, event: Event) -> Option<Event> {
3434
let cache_entry = build_cache_entry(&event, &self.fields);
3535
let now = Instant::now();
36-
let drop_event = if self.time_config.refresh_on_drop {
37-
self.cache
38-
.put(cache_entry, now)
39-
.is_some_and(|time| now.duration_since(time) < self.time_config.max_age_ms)
40-
} else if self
41-
.cache
42-
.get(&cache_entry)
43-
.is_some_and(|time| now.duration_since(*time) < self.time_config.max_age_ms)
44-
{
45-
true
46-
} else {
47-
self.cache.put(cache_entry, now);
48-
false
36+
let drop_event = match self.cache.get(&cache_entry) {
37+
Some(&time) => {
38+
let drop = now.duration_since(time) < self.time_config.max_age_ms;
39+
if self.time_config.refresh_on_drop || !drop {
40+
self.cache.put(cache_entry, now);
41+
}
42+
drop
43+
}
44+
None => {
45+
self.cache.put(cache_entry, now);
46+
false
47+
}
4948
};
5049
if drop_event {
5150
emit!(DedupeEventsDropped { count: 1 });

0 commit comments

Comments
 (0)