From f640daee4cf2993793b97cbeec14a596be5378e6 Mon Sep 17 00:00:00 2001 From: frosch Date: Wed, 2 Apr 2025 16:17:49 +0200 Subject: [PATCH] Codechange: No need for Utf8Consume and Utf8Encode, if only ASCII characters are checked. --- src/os/windows/crashlog_win.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/os/windows/crashlog_win.cpp b/src/os/windows/crashlog_win.cpp index 802802839d..c23bb4150a 100644 --- a/src/os/windows/crashlog_win.cpp +++ b/src/os/windows/crashlog_win.cpp @@ -494,14 +494,14 @@ static INT_PTR CALLBACK CrashDialogFunc(HWND wnd, UINT msg, WPARAM wParam, LPARA char *crashlog_dos_nl = reinterpret_cast(filename_buf + filename_buf_length * filename_count); /* Convert unix -> dos newlines because the edit box only supports that properly. */ - const char *crashlog_unix_nl = crashlog.c_str(); - char *p = crashlog_dos_nl; - char32_t c; - while ((c = Utf8Consume(&crashlog_unix_nl))) { - if (c == '\n') p += Utf8Encode(p, '\r'); - p += Utf8Encode(p, c); + { + char *p = crashlog_dos_nl; + for (char c : crashlog) { + if (c == '\n') *(p++) = '\r'; + *(p++) = c; + } + *p = '\0'; } - *p = '\0'; _snwprintf( crash_desc_buf,