refactor(clock): avoid usless time_point_cast
This commit is contained in:
parent
23d4a811db
commit
97bd637f5d
|
@ -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));
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue