From 4304fcfd89d66368d686ed19efb5b324cbb77df2 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 20 Feb 2018 03:03:28 +0300 Subject: [PATCH] Better double comparison. GitOrigin-RevId: 5a7092ce72e7531835d57455a8027819a6f03ab5 --- tdutils/td/utils/TimedStat.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tdutils/td/utils/TimedStat.h b/tdutils/td/utils/TimedStat.h index 3ab7e0c49..fc4197470 100644 --- a/tdutils/td/utils/TimedStat.h +++ b/tdutils/td/utils/TimedStat.h @@ -46,8 +46,11 @@ class TimedStat { StatT next_; double next_timestamp_; - void update(double now) { - CHECK(now >= next_timestamp_); + void update(double &now) { + if (now < next_timestamp_) { + CHECK(now >= next_timestamp_ * (1 - 1e-14)) << now << " " << next_timestamp_; + now = next_timestamp_; + } if (duration_ == 0) { return; }