From c58af22238f9b8d455b3b961b48aa0d5609c5d8e Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" Date: Wed, 19 May 2021 13:55:50 -0500 Subject: [PATCH] simplify logic --- runtime/src/accounts_db.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index 150c5ff7cc8c38..0be550a69a1207 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -1060,17 +1060,14 @@ impl ShrinkStats { // last is initialized to 0 by ::default() // thus, the first 'report' call would always log. // Instead, the first call now initialializes 'last_report' to now. - let first_call = last == 0; - let time_elapsed = !first_call && now.saturating_sub(last) > 1000; - let should_report = (first_call || time_elapsed) && { - let we_exchanged = - self.last_report - .compare_exchange(last, now, Ordering::Relaxed, Ordering::Relaxed) - == Ok(last); - we_exchanged && !first_call - }; - - if should_report { + let is_first_call = last == 0; + let should_report = now.saturating_sub(last) > 1000 + && self + .last_report + .compare_exchange(last, now, Ordering::Relaxed, Ordering::Relaxed) + == Ok(last); + + if !is_first_call && should_report { datapoint_info!( "shrink_stats", (