From 67884c38c639acab8e8f6649f3d4c340de8e2c2b Mon Sep 17 00:00:00 2001 From: Magnus Ulimoen Date: Tue, 17 Aug 2021 13:40:23 +0000 Subject: [PATCH] Simplify time tracking loop --- multigrid/src/main.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/multigrid/src/main.rs b/multigrid/src/main.rs index 99d33eb..fe748aa 100644 --- a/multigrid/src/main.rs +++ b/multigrid/src/main.rs @@ -115,15 +115,12 @@ fn main() { let mut itime = 0; while itime < ntime { - sys.advance(steps_between_outputs); + let nexttime = (itime + steps_between_outputs).max(ntime); + sys.advance(nexttime - itime); - itime += steps_between_outputs; + itime = nexttime; sys.output(itime); } - if itime != ntime { - sys.advance(ntime - itime); - sys.output(ntime); - } if !opt.no_progressbar { sys.finish_progressbar();