Skip to content

Commit d90c6a3

Browse files
committed
pp_reverse: Use isUTF8_CHAR() for validity check
The code was converting a UTF-8 single character string to its code point, just to find out if the string was wellformed or not. It had no need of the returned code point. It is more efficient to just use the function that checks for validity without trying to get the code point. The validity checking function returns 0 on failure; else how many bytes were in the string. Use this value instead of calling UTF8SKIP to re-derive it. And the former function utf8_to_uvchr_buf() is discouraged from use anyway. This commit removes the final core use of the discouraged _uvchr functions,
1 parent 09a0707 commit d90c6a3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6633,10 +6633,11 @@ PP_wrapped(pp_reverse, 0, 1)
66336633
continue;
66346634
}
66356635
else {
6636-
if (!utf8_to_uvchr_buf(s, send, 0))
6636+
Size_t advance = isUTF8_CHAR(s, send);
6637+
if (advance == 0)
66376638
break;
66386639
up = (char*)s;
6639-
s += UTF8SKIP(s);
6640+
s += advance;
66406641
down = (char*)(s - 1);
66416642
/* reverse this character */
66426643
while (down > up) {

0 commit comments

Comments
 (0)