Skip to content

Commit 339730a

Browse files
committed
logging: bypass timestamp formatting when not logging
This leads to massive speedups under Wine.
1 parent 39439e5 commit 339730a

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/util.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,16 @@ template<typename T, typename... Args> static inline void MarkUsed(const T& t, c
145145
#define LogPrint(category, ...) do { MarkUsed(__VA_ARGS__); } while(0)
146146
#else
147147
#define LogPrintf(...) do { \
148-
std::string _log_msg_; /* Unlikely name to avoid shadowing variables */ \
149-
try { \
150-
_log_msg_ = tfm::format(__VA_ARGS__); \
151-
} catch (tinyformat::format_error &fmterr) { \
152-
/* Original format string will have newline so don't add one here */ \
153-
_log_msg_ = "Error \"" + std::string(fmterr.what()) + "\" while formatting log message: " + FormatStringFromLogArgs(__VA_ARGS__); \
148+
if (fPrintToConsole || fPrintToDebugLog) { \
149+
std::string _log_msg_; /* Unlikely name to avoid shadowing variables */ \
150+
try { \
151+
_log_msg_ = tfm::format(__VA_ARGS__); \
152+
} catch (tinyformat::format_error &fmterr) { \
153+
/* Original format string will have newline so don't add one here */ \
154+
_log_msg_ = "Error \"" + std::string(fmterr.what()) + "\" while formatting log message: " + FormatStringFromLogArgs(__VA_ARGS__); \
155+
} \
156+
LogPrintStr(_log_msg_); \
154157
} \
155-
LogPrintStr(_log_msg_); \
156158
} while(0)
157159

158160
#define LogPrint(category, ...) do { \

0 commit comments

Comments
 (0)