Do not degrade performance over time

This commit is contained in:
45Tatami 2022-01-18 21:55:29 +01:00
parent e603a58a5d
commit 3f06f09553
1 changed files with 10 additions and 5 deletions

View File

@ -73,12 +73,17 @@ void log(string const& msg)
if (hwnd == NULL) if (hwnd == NULL)
return; return;
wstring cur = getEditBoxText(hwnd, IDC_LOG); wstring tmp = getEditBoxText(hwnd, IDC_LOG);
if (cur.length() > 0) if (tmp.length() > 0)
cur += L"\r\n"; tmp.append(L"\r\n");
// Remove older text to not slow down
if (tmp.length() > 4000) {
tmp.erase(0, 2000);
}
tmp.append(wstring_convert<codecvt_utf8_utf16<wchar_t>>().from_bytes(msg));
wstring tmp =
cur + wstring_convert<codecvt_utf8_utf16<wchar_t>>().from_bytes(msg);
SetDlgItemText(hwnd, IDC_LOG, tmp.c_str()); SetDlgItemText(hwnd, IDC_LOG, tmp.c_str());
SendMessage(GetDlgItem(hwnd, IDC_LOG), EM_LINESCROLL, 0, INT_MAX); SendMessage(GetDlgItem(hwnd, IDC_LOG), EM_LINESCROLL, 0, INT_MAX);
} }