summaryrefslogtreecommitdiff
path: root/utf8.h
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2020-06-30 14:04:24 -0600
committerKarl Williamson <khw@cpan.org>2021-05-28 15:23:57 -0600
commit08e4a1ef4d8dab2b623fc6d1bdad38d849b7d04f (patch)
tree939c0f2640fe2998474047b5f1c913a2aa45fcd9 /utf8.h
parent21e13fc5b2910e388a63ad33fba06559024fceb1 (diff)
downloadperl-08e4a1ef4d8dab2b623fc6d1bdad38d849b7d04f.tar.gz
utf8.h: Simplify UNICODE_IS_SURROGATE()
This uses inRANGE() with mnemonics to make it clearer with no increase in the number of conditionals
Diffstat (limited to 'utf8.h')
-rw-r--r--utf8.h7
1 files changed, 3 insertions, 4 deletions
diff --git a/utf8.h b/utf8.h
index 56bb283b2d..17d8b811d2 100644
--- a/utf8.h
+++ b/utf8.h
@@ -950,10 +950,9 @@ Evaluates to 0xFFFD, the code point of the Unicode REPLACEMENT CHARACTER
#define UNICODE_ALLOW_SUPER 0
#define UNICODE_ALLOW_ANY 0
-/* This matches the 2048 code points between UNICODE_SURROGATE_FIRST (0xD800) and
- * UNICODE_SURROGATE_LAST (0xDFFF) */
-#define UNICODE_IS_SURROGATE(uv) UNLIKELY(((UV) (uv) & (~0xFFFF | 0xF800)) \
- == 0xD800)
+/* This matches the 2048 code points between these */
+#define UNICODE_IS_SURROGATE(uv) UNLIKELY(inRANGE(uv, UNICODE_SURROGATE_FIRST, \
+ UNICODE_SURROGATE_LAST))
#define UNICODE_IS_REPLACEMENT(uv) UNLIKELY((UV) (uv) == UNICODE_REPLACEMENT)
#define UNICODE_IS_BYTE_ORDER_MARK(uv) UNLIKELY((UV) (uv) \