Skip to content

Commit

Permalink
fixup! feat: ScopedTimer ctor accept QString::arg-compatible format…
Browse files Browse the repository at this point in the history
…string
  • Loading branch information
Swiftb0y committed May 14, 2024
1 parent ededc5d commit c94babc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/util/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<typename... Ts>
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<Ts>(args)...);

Check failure on line 70 in src/util/timer.h

View workflow job for this annotation

GitHub Actions / clazy

no viable overloaded '='

Check failure on line 70 in src/util/timer.h

View workflow job for this annotation

GitHub Actions / clazy

no viable overloaded '='

Check failure on line 70 in src/util/timer.h

View workflow job for this annotation

GitHub Actions / clazy

no viable overloaded '='

Check failure on line 70 in src/util/timer.h

View workflow job for this annotation

GitHub Actions / clazy

no viable overloaded '='

Check failure on line 70 in src/util/timer.h

View workflow job for this annotation

GitHub Actions / Ubuntu 22.04 (gcc)

passing ‘const QString’ as ‘this’ argument discards qualifiers [-fpermissive]

Check failure on line 70 in src/util/timer.h

View workflow job for this annotation

GitHub Actions / Ubuntu 22.04 (gcc)

passing ‘const QString’ as ‘this’ argument discards qualifiers [-fpermissive]

Check failure on line 70 in src/util/timer.h

View workflow job for this annotation

GitHub Actions / coverage

passing ‘const QString’ as ‘this’ argument discards qualifiers [-fpermissive]

Check failure on line 70 in src/util/timer.h

View workflow job for this annotation

GitHub Actions / coverage

passing ‘const QString’ as ‘this’ argument discards qualifiers [-fpermissive]

Check failure on line 70 in src/util/timer.h

View workflow job for this annotation

GitHub Actions / coverage

passing ‘const QString’ as ‘this’ argument discards qualifiers [-fpermissive]

Check failure on line 70 in src/util/timer.h

View workflow job for this annotation

GitHub Actions / coverage

passing ‘const QString’ as ‘this’ argument discards qualifiers [-fpermissive]

Check failure on line 70 in src/util/timer.h

View workflow job for this annotation

GitHub Actions / Ubuntu 22.04 (Qt 6.2, gcc)

passing ‘const QString’ as ‘this’ argument discards qualifiers [-fpermissive]

Check failure on line 70 in src/util/timer.h

View workflow job for this annotation

GitHub Actions / Windows 2019 (MSVC)

binary '=': no operator found which takes a left-hand operand of type 'const QString' (or there is no acceptable conversion)
}
m_timer = std::make_optional<Timer>(key, compute);
m_timer = std::make_optional<Timer>(assembledKey, compute);
m_timer->start();
}
}
template<typename... Ts>
ScopedTimer(QString key, Ts&&... args)
ScopedTimer(const QString& key, Ts&&... args)
: ScopedTimer(kDefaultComputeFlags, key, std::forward<Ts>(args)...) {
}
// for lazy users that don't wrap the key in a QStringLiteral(...)
Expand Down

0 comments on commit c94babc

Please sign in to comment.