summaryrefslogtreecommitdiff
path: root/utf8.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2019-12-08 09:20:55 -0700
committerKarl Williamson <khw@cpan.org>2019-12-26 14:02:25 -0700
commitb497502cc8727ca990d121fbb40d3198e6bae3eb (patch)
tree047df11b8b309827236eac09dfe38a6142164fab /utf8.c
parent25faa0d3730537ee32a3a4646abedc33b31e0d37 (diff)
downloadperl-b497502cc8727ca990d121fbb40d3198e6bae3eb.tar.gz
utf8.c: Use inRANGE
It is clearer and faster
Diffstat (limited to 'utf8.c')
-rw-r--r--utf8.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/utf8.c b/utf8.c
index 2d4c8fb8d1..0f49d5dbba 100644
--- a/utf8.c
+++ b/utf8.c
@@ -2750,16 +2750,16 @@ Perl_utf16_to_utf8(pTHX_ U8* p, U8* d, I32 bytelen, I32 *newlen)
/* This assumes that most uses will be in the first Unicode plane, not
* needing surrogates */
- if (UNLIKELY(uv >= UNICODE_SURROGATE_FIRST
- && uv <= UNICODE_SURROGATE_LAST))
+ if (UNLIKELY(inRANGE(uv, UNICODE_SURROGATE_FIRST,
+ UNICODE_SURROGATE_LAST)))
{
if (UNLIKELY(p >= pend) || UNLIKELY(uv > LAST_HIGH_SURROGATE)) {
Perl_croak(aTHX_ "Malformed UTF-16 surrogate");
}
else {
UV low = (p[0] << 8) + p[1];
- if ( UNLIKELY(low < FIRST_LOW_SURROGATE)
- || UNLIKELY(low > LAST_LOW_SURROGATE))
+ if (UNLIKELY(! inRANGE(low, FIRST_LOW_SURROGATE,
+ LAST_LOW_SURROGATE)))
{
Perl_croak(aTHX_ "Malformed UTF-16 surrogate");
}