From aacc849b92da13c1abc5b61e3d3c58d7016e3caf Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sun, 16 May 2021 16:07:11 -0600 Subject: [PATCH] utf8.h: Refactor UNICODE_IS_NONCHAR() 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 --- utf8.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utf8.h b/utf8.h index 3bec01989f94..20b845734cd4 100644 --- a/utf8.h +++ b/utf8.h @@ -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)