summaryrefslogtreecommitdiff
path: root/src/debug/Log.hpp
diff options
context:
space:
mode:
authorIkalco <73481042+ikalco@users.noreply.github.com>2024-08-28 06:19:06 -0500
committerGitHub <noreply@github.com>2024-08-28 13:19:06 +0200
commit7dd0f76e5aa1e3726f9d9fd1871bc667237ef6a8 (patch)
tree775c6369d3db56404651d602a309a9b44e1dbed3 /src/debug/Log.hpp
parent17ed4fc04cedbaad365bdebf6bfe0160c527f3fe (diff)
logs: don't get timezone every time logging (#7550)
its expensive cause cpp dum
Diffstat (limited to 'src/debug/Log.hpp')
-rw-r--r--src/debug/Log.hpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/debug/Log.hpp b/src/debug/Log.hpp
index 4fc8ed5b..d3190d4f 100644
--- a/src/debug/Log.hpp
+++ b/src/debug/Log.hpp
@@ -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())};