Skip to content

Commit fadda7d

Browse files
committed
utf8n_to_uvchr_msgs_helper: Don't throw away work
Admittedly not much work, but I realized in code reading that there are function exits that ignore this initialization. Instead move the initialization to later, where it is actually needed
1 parent 1d9f041 commit fadda7d

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

utf8.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,8 +1456,7 @@ Perl__utf8n_to_uvchr_msgs_helper(const U8 *s,
14561456
}
14571457

14581458
/* We now know we can examine the first byte of the input */
1459-
expectlen = UTF8SKIP(s);
1460-
uv = *s;
1459+
expectlen = UTF8SKIP(s0);
14611460

14621461
/* This is a helper function; invariants should have been handled before
14631462
* calling it */
@@ -1472,7 +1471,7 @@ Perl__utf8n_to_uvchr_msgs_helper(const U8 *s,
14721471
}
14731472

14741473
/* A continuation character can't start a valid sequence */
1475-
if (UNLIKELY(UTF8_IS_CONTINUATION(uv))) {
1474+
if (UNLIKELY(UTF8_IS_CONTINUATION(*s0))) {
14761475
possible_problems |= UTF8_GOT_CONTINUATION;
14771476
curlen = 1;
14781477
uv = UNICODE_REPLACEMENT;
@@ -1487,7 +1486,7 @@ Perl__utf8n_to_uvchr_msgs_helper(const U8 *s,
14871486
/* Convert to I8 on EBCDIC (no-op on ASCII), then remove the leading bits
14881487
* that indicate the number of bytes in the character's whole UTF-8
14891488
* sequence, leaving just the bits that are part of the value. */
1490-
uv = NATIVE_UTF8_TO_I8(uv) & UTF_START_MASK(expectlen);
1489+
uv = NATIVE_UTF8_TO_I8(*s0) & UTF_START_MASK(expectlen);
14911490

14921491
/* Setup the loop end point, making sure to not look past the end of the
14931492
* input string, and flag it as too short if the size isn't big enough. */

0 commit comments

Comments
 (0)