Skip to content

Commit d4e2765

Browse files
committed
utf8n_to_uvchr_msgs: Hoist conditional outside loop
This slight refactoring speeds this important loop up a bit.
1 parent 1910ef2 commit d4e2765

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

inline.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3035,19 +3035,19 @@ Perl_utf8n_to_uvchr_msgs(const U8 *s,
30353035
UV state = PL_strict_utf8_dfa_tab[256 + type];
30363036
uv = (0xff >> type) & NATIVE_UTF8_TO_I8(*s);
30373037

3038-
while (LIKELY(state != 1) && ++s < send) {
3038+
while (state > 1 && ++s < send) {
30393039
type = PL_strict_utf8_dfa_tab[*s];
30403040
state = PL_strict_utf8_dfa_tab[256 + state + type];
30413041

30423042
uv = UTF8_ACCUMULATE(uv, *s);
3043+
}
30433044

30443045
if (state == 0) {
30453046
#ifdef EBCDIC
30463047
uv = UNI_TO_NATIVE(uv);
30473048
#endif
30483049
goto success;
30493050
}
3050-
}
30513051

30523052
/* Here is potentially problematic. Use the full mechanism */
30533053
return _utf8n_to_uvchr_msgs_helper(s0, curlen, retlen, flags,

0 commit comments

Comments
 (0)