Skip to content

Commit

Permalink
utf8.h: Refactor UNICODE_IS_NONCHAR()
Browse files Browse the repository at this point in the history
This adds branch prediction and re-orders so that an unlikely to succeed
test is done before the likely to succeed one, so that the latter
usually doesn't need to be executed.  Since both conditions must succeed
for the entire expression to succeed, this doesn't change what the whole
expresson matches.

s# Please enter the commit message for your changes. Lines starting
  • Loading branch information
khwilliamson committed May 28, 2021
1 parent 573d6c0 commit aacc849
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions utf8.h
Expand Up @@ -970,9 +970,9 @@ Evaluates to 0xFFFD, the code point of the Unicode REPLACEMENT CHARACTER
UNLIKELY(((UV) (uv) & 0xFFFE) == 0xFFFE)

#define UNICODE_IS_NONCHAR(uv) \
( UNICODE_IS_32_CONTIGUOUS_NONCHARS(uv) \
|| ( LIKELY( ! UNICODE_IS_SUPER(uv)) \
&& UNICODE_IS_END_PLANE_NONCHAR_GIVEN_NOT_SUPER(uv)))
( UNLIKELY(UNICODE_IS_32_CONTIGUOUS_NONCHARS(uv)) \
|| ( UNLIKELY(UNICODE_IS_END_PLANE_NONCHAR_GIVEN_NOT_SUPER(uv)) \
&& LIKELY(! UNICODE_IS_SUPER(uv))))

#define UNICODE_IS_SUPER(uv) UNLIKELY((UV) (uv) > PERL_UNICODE_MAX)

Expand Down

0 comments on commit aacc849

Please sign in to comment.