tweaks: speed up the counting of characters in mbstrlen()

This function is used in get_totsize(), so speed is important.

There is no reason why the length of the string must limited to a
certain size -- that is just a leftover from the function merge in
commit ba2e6f43 from a year ago.
master
Benno Schulenberg 2019-06-09 10:47:30 +02:00
parent fb17929fab
commit 7be76af418
1 changed files with 1 additions and 9 deletions

View File

@ -506,13 +506,9 @@ char *mbrevstrcasestr(const char *haystack, const char *needle,
/* Count the number of (multibyte) characters in the given string. */
size_t mbstrlen(const char *s)
{
size_t maxlen = (size_t)-1;
#ifdef ENABLE_UTF8
if (use_utf8) {
size_t n = 0;
while (*s != '\0' && maxlen > 0) {
while (*s != '\0') {
if ((signed char)*s < 0) {
int length = mblen(s, MAXCHARLEN);
@ -520,14 +516,10 @@ size_t mbstrlen(const char *s)
} else
s++;
maxlen--;
n++;
}
return n;
} else
#endif
return strnlen(s, maxlen);
}
#if !defined(NANO_TINY) || defined(ENABLE_JUSTIFY)