From 747650497886e5065f3903e6cd7cafbd4e284b70 Mon Sep 17 00:00:00 2001 From: Poliorcetics Date: Fri, 11 Aug 2023 18:25:00 +0200 Subject: [PATCH] Move reset to seperate function (#10) --- src/worker.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/worker.rs b/src/worker.rs index 43a7c27..7b72257 100644 --- a/src/worker.rs +++ b/src/worker.rs @@ -157,11 +157,7 @@ impl Worker { // TODO: be smarter around reusing past results for rescoring if self.pattern.cols.iter().all(|pat| pat.is_empty()) { - self.matches.clear(); - self.matches - .extend((0..self.last_snapshot).map(|idx| Match { score: 0, idx })); - // there are usually only very few in flight items (one for each writer) - self.remove_in_flight_matches(); + self.reset_matches(); self.process_new_items_trivial(); if self.should_notify.load(atomic::Ordering::Relaxed) { (self.notify)(); @@ -170,10 +166,7 @@ impl Worker { } if pattern_status == pattern::Status::Rescore { - self.matches.clear(); - self.matches - .extend((0..self.last_snapshot).map(|idx| Match { score: 0, idx })); - self.remove_in_flight_matches(); + self.reset_matches(); } let mut unmatched = AtomicU32::new(0); @@ -250,4 +243,12 @@ impl Worker { } } } + + fn reset_matches(&mut self) { + self.matches.clear(); + self.matches + .extend((0..self.last_snapshot).map(|idx| Match { score: 0, idx })); + // there are usually only very few in flight items (one for each writer) + self.remove_in_flight_matches(); + } }