From: Paul Eggert Date: Thu, 23 Apr 2020 01:58:45 +0000 (-0700) Subject: Tweak multibyte parsing loops X-Git-Tag: emacs-28.0.90~7531 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=023ff119fb511e262e7cd64b8abb7482720ac4a6;p=emacs.git Tweak multibyte parsing loops * src/character.c (parse_str_as_multibyte, str_as_multibyte): Let the fast loop run a little longer, fixing what appears to be an off-by-1 performance nit. --- diff --git a/src/character.c b/src/character.c index da09e77e131..edcec5f1c79 100644 --- a/src/character.c +++ b/src/character.c @@ -512,7 +512,7 @@ parse_str_as_multibyte (const unsigned char *str, ptrdiff_t len, if (len >= MAX_MULTIBYTE_LENGTH) { - const unsigned char *adjusted_endp = endp - MAX_MULTIBYTE_LENGTH; + const unsigned char *adjusted_endp = endp - (MAX_MULTIBYTE_LENGTH - 1); while (str < adjusted_endp) { int n = multibyte_length (str, NULL, false, false); @@ -556,7 +556,7 @@ str_as_multibyte (unsigned char *str, ptrdiff_t len, ptrdiff_t nbytes, if (nbytes >= MAX_MULTIBYTE_LENGTH) { - unsigned char *adjusted_endp = endp - MAX_MULTIBYTE_LENGTH; + unsigned char *adjusted_endp = endp - (MAX_MULTIBYTE_LENGTH - 1); while (p < adjusted_endp) { int n = multibyte_length (p, NULL, false, false); @@ -585,7 +585,7 @@ str_as_multibyte (unsigned char *str, ptrdiff_t len, ptrdiff_t nbytes, if (nbytes >= MAX_MULTIBYTE_LENGTH) { - unsigned char *adjusted_endp = endp - MAX_MULTIBYTE_LENGTH; + unsigned char *adjusted_endp = endp - (MAX_MULTIBYTE_LENGTH - 1); while (p < adjusted_endp) { int n = multibyte_length (p, NULL, false, false);