Skip to content

Commit

Permalink
logs: don't get timezone every time logging (#7550)
Browse files Browse the repository at this point in the history
its expensive cause cpp dum
  • Loading branch information
ikalco authored Aug 28, 2024
1 parent 17ed4fc commit 7dd0f76
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/debug/Log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ namespace Debug {
// print date and time to the ofs
if (disableTime && !**disableTime) {
#ifndef _LIBCPP_VERSION
const auto zt = std::chrono::zoned_time{std::chrono::current_zone(), std::chrono::system_clock::now()};
const auto hms = std::chrono::hh_mm_ss{zt.get_local_time() - std::chrono::floor<std::chrono::days>(zt.get_local_time())};
static auto current_zone = std::chrono::current_zone();
const auto zt = std::chrono::zoned_time{current_zone, std::chrono::system_clock::now()};
const auto hms = std::chrono::hh_mm_ss{zt.get_local_time() - std::chrono::floor<std::chrono::days>(zt.get_local_time())};
#else
// TODO: current clang 17 does not support `zoned_time`, remove this once clang 19 is ready
const auto hms = std::chrono::hh_mm_ss{std::chrono::system_clock::now() - std::chrono::floor<std::chrono::days>(std::chrono::system_clock::now())};
Expand Down

0 comments on commit 7dd0f76

Please sign in to comment.