tweaks: reorder some code, to further optimize display_string() for ASCII

The majority of characters in the files that get edited with nano will
be single-byte printable ASCII characters, so their case should come
first in the main loop of display_string().
This commit is contained in:
Benno Schulenberg 2019-06-11 11:21:29 +02:00
parent 5c4b0b38f4
commit ed40fd8031

View File

@ -1924,6 +1924,13 @@ char *display_string(const char *buf, size_t column, size_t span,
while (*buf != '\0' && (column < beyond || mbwidth(buf) == 0)) {
int charlength, charwidth;
/* A plain printable ASCII character is one byte, one column. */
if ((signed char)*buf > 0x20 && *buf != DEL_CODE) {
converted[index++] = *(buf++);
column++;
continue;
}
/* Show a space as a visible character, or as a space. */
if (*buf == ' ') {
#ifndef NANO_TINY
@ -1968,13 +1975,6 @@ char *display_string(const char *buf, size_t column, size_t span,
continue;
}
/* A normal, one-byte character is necessarily one column wide. */
if ((signed char)*buf > 0) {
converted[index++] = *(buf++);
column++;
continue;
}
#ifdef ENABLE_UTF8
wchar_t wc;