Skip to content

Commit

Permalink
Windows: avoid unnecessary UTF-8 conversion when repeat count >1.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwsw committed Oct 5, 2023
1 parent c53524e commit 4ad71af
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -2986,6 +2986,9 @@ static int win32_scan_code(XINPUT_RECORD *xip)
static int win32_key_event(XINPUT_RECORD *xip)
{
int repeat;
char utf8[UTF8_MAX_LENGTH];
char *up;
char *p;

if (xip->ir.EventType != KEY_EVENT ||
((xip->ir.Event.KeyEvent.dwControlKeyState & (RIGHT_ALT_PRESSED|LEFT_CTRL_PRESSED)) == (RIGHT_ALT_PRESSED|LEFT_CTRL_PRESSED) && xip->ir.Event.KeyEvent.uChar.UnicodeChar == 0) ||
Expand All @@ -3009,12 +3012,10 @@ static int win32_key_event(XINPUT_RECORD *xip)
repeat = xip->ir.Event.KeyEvent.wRepeatCount;
if (repeat > WIN32_MAX_REPEAT)
repeat = WIN32_MAX_REPEAT;
up = utf8;
put_wchar(&up, xip->ichar);
for (; repeat > 0; --repeat)
{
char utf8[UTF8_MAX_LENGTH];
char *up = utf8;
char *p;
put_wchar(&up, xip->ichar);
for (p = utf8; p < up; ++p)
win32_enqueue(*p);
}
Expand Down

0 comments on commit 4ad71af

Please sign in to comment.