From 58235d3709025d9530b3518238d2cb3dc7954763 Mon Sep 17 00:00:00 2001 From: RumovZ Date: Sat, 30 Apr 2022 09:14:56 +0200 Subject: [PATCH] Move update_interval into IncrementableProgress --- rslib/src/import_export/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rslib/src/import_export/mod.rs b/rslib/src/import_export/mod.rs index 8f9825e59..171c7bd32 100644 --- a/rslib/src/import_export/mod.rs +++ b/rslib/src/import_export/mod.rs @@ -21,10 +21,9 @@ pub(crate) struct IncrementableProgress

{ progress_fn: Box bool>, count_map: Option P>>, count: usize, + update_interval: usize, } -const UPDATE_INTERVAL: usize = 17; - impl

IncrementableProgress

{ /// `progress_fn: (progress, throttle) -> should_continue` pub(crate) fn new(progress_fn: impl 'static + FnMut(P, bool) -> bool) -> Self { @@ -32,6 +31,7 @@ impl

IncrementableProgress

{ progress_fn: Box::new(progress_fn), count_map: None, count: 0, + update_interval: 17, } } @@ -47,7 +47,7 @@ impl

IncrementableProgress

{ /// Must have called `set_count_map()` before calling this. pub(crate) fn increment(&mut self) -> Result<()> { self.count += 1; - if self.count % UPDATE_INTERVAL != 0 { + if self.count % self.update_interval != 0 { return Ok(()); } let progress = self.mapped_progress()?;