From a5c7b65869cb7e318db0ba5f04e862218b906fdd Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Wed, 11 Jan 2023 18:26:58 +0300 Subject: [PATCH] perf: avoid extra time() call (#4577) --- libtransmission/session.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libtransmission/session.cc b/libtransmission/session.cc index 11b61a24d..cc5556a8e 100644 --- a/libtransmission/session.cc +++ b/libtransmission/session.cc @@ -609,13 +609,13 @@ tr_session* tr_sessionInit(char const* config_dir, bool message_queueing_enabled void tr_session::onNowTimer() { TR_ASSERT(now_timer_); + auto const now = std::chrono::system_clock::now(); // tr_session upkeep tasks to perform once per second - tr_timeUpdate(time(nullptr)); + tr_timeUpdate(std::chrono::system_clock::to_time_t(now)); alt_speeds_.checkScheduler(); // set the timer to kick again right after (10ms after) the next second - auto const now = std::chrono::system_clock::now(); auto const target_time = std::chrono::time_point_cast(now) + 1s + 10ms; auto target_interval = target_time - now; if (target_interval < 100ms)