nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 4e667bd048c813a410eea7e68a2b7c0c980330ee
parent ba2e6f43c284770eac121eb418c43414e8fde953
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sun,  3 Jun 2018 17:58:05 +0200

tweaks: reduce the counting of characters to just the needed function

Evade the indirect use of the general-purpose function parse_mbchar().
This reduces the counting time by roughly ten percent.

Diffstat:
Msrc/chars.c | 10+++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/chars.c b/src/chars.c @@ -539,9 +539,13 @@ size_t mbstrlen(const char *s) if (use_utf8) { size_t n = 0; - for (; *s != '\0' && maxlen > 0; s += move_mbright(s, 0), - maxlen--, n++) - ; + while (*s != '\0' && maxlen > 0) { + int length = mblen(s, MAXCHARLEN); + + s += (length < 0 ? 1 : length); + maxlen--; + n++; + } return n; } else