perf: skip LOGF formatting when logging is silent

LOGF/LOGF_COLOR always ran fmt::sprintf even when the output was discarded; at
emulator log volume the formatting alone costs frames. Add Log::IsSilent() and
short-circuit before formatting. Behavior-preserving on all platforms (it only
skips work whose result is thrown away); before init it reports non-silent so
early logs still print.

(cherry picked from commit 1749e0fc68ae4290055fb12f72c9bb4baf466190)
This commit is contained in:
Abdullah K.
2026-07-23 04:32:44 +05:00
committed by nmzik
parent 7921269878
commit 31ea0081a9
2 changed files with 18 additions and 2 deletions
+5
View File
@@ -178,6 +178,11 @@ Direction GetDirection() {
return g_direction;
}
bool IsSilent() {
// Before init LOGF must keep writing to stdout, so report non-silent.
return g_initialized && g_direction == Direction::Silent;
}
void Write(std::string_view text) {
WriteImpl(text);
}