refactor(clock): avoid usless time_point_cast

This commit is contained in:
Alex 2019-05-22 11:51:33 +02:00
parent 23d4a811db
commit 97bd637f5d
1 changed files with 2 additions and 4 deletions

View File

@ -10,10 +10,8 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
dp.emit(); dp.emit();
auto now = std::chrono::system_clock::now(); auto now = std::chrono::system_clock::now();
auto timeout = std::chrono::floor<std::chrono::seconds>(now + interval_); auto timeout = std::chrono::floor<std::chrono::seconds>(now + interval_);
auto time_point = auto diff = std::chrono::seconds(timeout.time_since_epoch().count() % interval_.count());
std::chrono::time_point_cast<std::chrono::seconds>(timeout).time_since_epoch().count() % thread_.sleep_until(timeout - diff);
interval_.count();
thread_.sleep_until(timeout - std::chrono::seconds(time_point));
}; };
} }