This actually does two things: 1) it adds macros that evaluate to no
extra code on ASCII platforms, but allow things to work under EBCDIC;
and 2) it changes to use a ternary conditional. This may not change
anything, or it may cause the compiler to generate slightly smaller
code at the expense of an extra addition instruction. I am moving to
inlining this code, and want to make it smaller to enable that to
happen.
while (s < send && LIKELY(state != PERL_UTF8_DECODE_REJECT)) {
UV type = dfa_tab_for_perl[*s];
- if (state != 0) {
- uv = (*s & 0x3fu) | (uv << UTF_ACCUMULATION_SHIFT);
- state = dfa_tab_for_perl[256 + state + type];
- }
- else {
- uv = (0xff >> type) & (*s);
- state = dfa_tab_for_perl[256 + type];
- }
+ uv = (state == 0)
+ ? ((0xff >> type) & NATIVE_UTF8_TO_I8(*s))
+ : UTF8_ACCUMULATE(uv, *s);
+ state = dfa_tab_for_perl[256 + state + type];
if (state == 0) {
goto got_uv;
}
- return uv;
+ return UNI_TO_NATIVE(uv);
}
s++;