commit ed40fd8031ffe802608949c176bdb4bb02d4b0dd
parent 5c4b0b38f408363e9718e72230f786e486386dd6
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Tue, 11 Jun 2019 11:21:29 +0200
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().
Diffstat:
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/winio.c b/src/winio.c
@@ -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;