[USETUP] Speed up CONSOLE_SetStatusTextXV +17% (#5086)

Get more speed by omitting erasing and overwriting whole line. CORE-18838
This commit is contained in:
Katayama Hirofumi MZ 2023-02-21 09:14:26 +09:00 committed by GitHub
parent f1de615b9c
commit acd3148c1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -429,32 +429,26 @@ CONSOLE_SetStatusTextXV(
IN LPCSTR fmt, IN LPCSTR fmt,
IN va_list args) IN va_list args)
{ {
INT nLength;
COORD coPos; COORD coPos;
DWORD Written; DWORD Written;
CHAR Buffer[128]; CHAR Buffer[128];
vsprintf(Buffer, fmt, args); memset(Buffer, ' ', min(sizeof(Buffer), xScreen));
nLength = vsprintf(&Buffer[x], fmt, args);
ASSERT(x + nLength < sizeof(Buffer));
Buffer[x + nLength] = ' ';
coPos.X = 0; coPos.X = 0;
coPos.Y = yScreen - 1; coPos.Y = yScreen - 1;
FillConsoleOutputAttribute(StdOutput, FillConsoleOutputAttribute(StdOutput,
BACKGROUND_WHITE, BACKGROUND_WHITE,
xScreen, xScreen,
coPos, coPos,
&Written); &Written);
FillConsoleOutputCharacterA(StdOutput,
' ',
xScreen,
coPos,
&Written);
coPos.X = x;
WriteConsoleOutputCharacterA(StdOutput, WriteConsoleOutputCharacterA(StdOutput,
Buffer, Buffer,
(ULONG)strlen(Buffer), min(sizeof(Buffer), xScreen),
coPos, coPos,
&Written); &Written);
} }