Skip to content

Commit

Permalink
logging: bypass timestamp formatting when not logging
Browse files Browse the repository at this point in the history
This leads to massive speedups under Wine.
  • Loading branch information
theuni committed Apr 12, 2018
1 parent 39439e5 commit 339730a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,16 @@ template<typename T, typename... Args> static inline void MarkUsed(const T& t, c
#define LogPrint(category, ...) do { MarkUsed(__VA_ARGS__); } while(0)
#else
#define LogPrintf(...) do { \
std::string _log_msg_; /* Unlikely name to avoid shadowing variables */ \
try { \
_log_msg_ = tfm::format(__VA_ARGS__); \
} catch (tinyformat::format_error &fmterr) { \
/* Original format string will have newline so don't add one here */ \
_log_msg_ = "Error \"" + std::string(fmterr.what()) + "\" while formatting log message: " + FormatStringFromLogArgs(__VA_ARGS__); \
if (fPrintToConsole || fPrintToDebugLog) { \
std::string _log_msg_; /* Unlikely name to avoid shadowing variables */ \
try { \
_log_msg_ = tfm::format(__VA_ARGS__); \
} catch (tinyformat::format_error &fmterr) { \
/* Original format string will have newline so don't add one here */ \
_log_msg_ = "Error \"" + std::string(fmterr.what()) + "\" while formatting log message: " + FormatStringFromLogArgs(__VA_ARGS__); \
} \
LogPrintStr(_log_msg_); \
} \
LogPrintStr(_log_msg_); \
} while(0)

#define LogPrint(category, ...) do { \
Expand Down

0 comments on commit 339730a

Please sign in to comment.