tweaks: use knowledge of Unicode to skip the general multibyte conversion

The relevant range is so small (128 bytes) that "manual" conversion
is much faster (and a bit shorter, eliding two variables).
This commit is contained in:
Benno Schulenberg 2020-07-20 19:27:56 +02:00
parent 17a8b24fe5
commit 43b39ed04f

View File

@ -995,21 +995,20 @@ int parse_kbinput(WINDOW *win)
return ERR; return ERR;
#ifdef ENABLE_UTF8 #ifdef ENABLE_UTF8
else if (byte > 0x7F && using_utf8()) { else if (byte > 0x7F && using_utf8()) {
int count; /* Convert the code to the corresponding Unicode. */
/* Convert the decimal code to two bytes. */ if (byte < 0xC0) {
char *multibyte = make_mbchar((long)byte, &count); put_back((unsigned char)byte);
put_back(0xC2);
/* Insert the two bytes into the input buffer. */ } else {
put_back((unsigned char)multibyte[1]); put_back((unsigned char)(byte - 0x40));
put_back((unsigned char)multibyte[0]); put_back(0xC3);
}
free(multibyte);
escapes = 0; escapes = 0;
} }
#endif #endif
else { else {
retval = byte;
escapes = 0; escapes = 0;
return byte;
} }
} else { } else {
if (digit_count > 0) if (digit_count > 0)