nano

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

commit 85ebe971e205084655a8abeaff42e3b0ff27d752
parent fc101a6deddb56ba2e95d812115493a18a61e39a
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Thu, 15 Dec 2016 16:45:26 +0100

chars: optimize for the most common case

That is: elide a second test from the most travelled path: a valid
character.  This adds a second call of mblen() when parse_mbchar()
is called on a terminating zero, but that should never happen.

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

diff --git a/src/chars.c b/src/chars.c @@ -382,11 +382,10 @@ int parse_mbchar(const char *buf, char *chr, size_t *col) length = mblen(buf, MB_CUR_MAX); /* When the multibyte sequence is invalid, only take the first byte. */ - if (length < 0) { + if (length <= 0) { IGNORE_CALL_RESULT(mblen(NULL, 0)); length = 1; - } else if (length == 0) - length = 1; + } /* When requested, store the multibyte character in chr. */ if (chr != NULL) {