From c94babca0e23c80e6e5ac01475341a39317d48f4 Mon Sep 17 00:00:00 2001 From: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com> Date: Tue, 14 May 2024 17:36:15 +0200 Subject: [PATCH] fixup! feat: ScopedTimer ctor accept `QString::arg-compatible` formatstring --- src/util/timer.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/util/timer.h b/src/util/timer.h index af61ab59ad98..5a46a3cdf58e 100644 --- a/src/util/timer.h +++ b/src/util/timer.h @@ -61,19 +61,20 @@ class ScopedTimer { /// @param key The format string for the key /// @param args The arguments to pass to the format string template - ScopedTimer(Stat::ComputeFlags compute, QString key, Ts&&... args) + ScopedTimer(Stat::ComputeFlags compute, const QString& key, Ts&&... args) : m_timer(std::nullopt) { if (CmdlineArgs::Instance().getDeveloper()) { + QString assembledKey = key; if constexpr (sizeof...(args) > 0) { // only try to call QString::arg when we've been given parameters key = key.arg(std::forward(args)...); } - m_timer = std::make_optional(key, compute); + m_timer = std::make_optional(assembledKey, compute); m_timer->start(); } } template - ScopedTimer(QString key, Ts&&... args) + ScopedTimer(const QString& key, Ts&&... args) : ScopedTimer(kDefaultComputeFlags, key, std::forward(args)...) { } // for lazy users that don't wrap the key in a QStringLiteral(...)