Skip to content

Commit bff7ff5

Browse files
committed
utf8.c: Further simplify complex conditional
This splits these into an if clause, and an else clause
1 parent 626cad2 commit bff7ff5

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

utf8.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,16 +1601,11 @@ Perl__utf8n_to_uvchr_msgs_helper(const U8 *s,
16011601
* the overflow handling code */
16021602
&& LIKELY(! (possible_problems & UTF8_GOT_OVERFLOW)))
16031603
{
1604-
/* uv is valid for overlongs */
1605-
if ( ( LIKELY(! (possible_problems & ~UTF8_GOT_LONG))
1606-
&& isUNICODE_POSSIBLY_PROBLEMATIC(uv))
1607-
|| ( UNLIKELY(possible_problems)
1608-
&& ( isUTF8_POSSIBLY_PROBLEMATIC(*adjusted_s0)
1609-
|| UNLIKELY(UTF8_IS_PERL_EXTENDED(s0)))))
1610-
{
16111604
/* If there were no malformations, or the only malformation is an
16121605
* overlong, 'uv' is valid */
1613-
if (LIKELY(! (possible_problems & ~UTF8_GOT_LONG))) {
1606+
if ( LIKELY(! (possible_problems & ~UTF8_GOT_LONG))
1607+
&& isUNICODE_POSSIBLY_PROBLEMATIC(uv))
1608+
{
16141609
if (UNLIKELY(UNICODE_IS_SURROGATE(uv))) {
16151610
possible_problems |= UTF8_GOT_SURROGATE;
16161611
}
@@ -1621,9 +1616,12 @@ Perl__utf8n_to_uvchr_msgs_helper(const U8 *s,
16211616
possible_problems |= UTF8_GOT_NONCHAR;
16221617
}
16231618
}
1624-
else { /* Otherwise, need to look at the source UTF-8, possibly
1625-
adjusted to be non-overlong */
1626-
1619+
else if ( UNLIKELY(possible_problems)
1620+
/* Otherwise, need to look at the source UTF-8,
1621+
* possibly adjusted to be non-overlong */
1622+
&& ( isUTF8_POSSIBLY_PROBLEMATIC(*adjusted_s0)
1623+
|| UNLIKELY(UTF8_IS_PERL_EXTENDED(s0))))
1624+
{
16271625
if (UNLIKELY(NATIVE_UTF8_TO_I8(*adjusted_s0)
16281626
> UTF_START_BYTE_110000_))
16291627
{
@@ -1645,7 +1643,6 @@ Perl__utf8n_to_uvchr_msgs_helper(const U8 *s,
16451643
/* We need a complete well-formed UTF-8 character to discern
16461644
* non-characters, so can't look for them here */
16471645
}
1648-
}
16491646
}
16501647

16511648
ready_to_handle_errors:

0 commit comments

Comments
 (0)