https://git.reactos.org/?p=reactos.git;a=commitdiff;h=acd3148c1a52dfa1eb870…
commit acd3148c1a52dfa1eb870d074d9071bbf2b67f26
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Tue Feb 21 09:14:26 2023 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Tue Feb 21 09:14:26 2023 +0900
[USETUP] Speed up CONSOLE_SetStatusTextXV +17% (#5086)
Get more speed by omitting erasing and overwriting whole line. CORE-18838
---
base/setup/usetup/consup.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/base/setup/usetup/consup.c b/base/setup/usetup/consup.c
index 15e0fa69d99..9c3c799e63f 100644
--- a/base/setup/usetup/consup.c
+++ b/base/setup/usetup/consup.c
@@ -429,32 +429,26 @@ CONSOLE_SetStatusTextXV(
IN LPCSTR fmt,
IN va_list args)
{
+ INT nLength;
COORD coPos;
DWORD Written;
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.Y = yScreen - 1;
-
FillConsoleOutputAttribute(StdOutput,
BACKGROUND_WHITE,
xScreen,
coPos,
&Written);
-
- FillConsoleOutputCharacterA(StdOutput,
- ' ',
- xScreen,
- coPos,
- &Written);
-
- coPos.X = x;
-
WriteConsoleOutputCharacterA(StdOutput,
Buffer,
- (ULONG)strlen(Buffer),
+ min(sizeof(Buffer), xScreen),
coPos,
&Written);
}