mirror of
git://git.sv.gnu.org/nano.git
synced 2024-11-25 22:29:42 +03:00
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.
This commit is contained in:
parent
ba2e6f43c2
commit
4e667bd048
10
src/chars.c
10
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
|
||||
|
Loading…
Reference in New Issue
Block a user