utf8n_to_uvchr(): Avoid some work
authorKarl Williamson <khw@cpan.org>
Tue, 27 Jun 2017 04:08:01 +0000 (22:08 -0600)
committerKarl Williamson <khw@cpan.org>
Thu, 13 Jul 2017 03:14:23 +0000 (21:14 -0600)
By adding a single mask, we can avoid some unnecessary work, as that
work is not necessary if just the one bit is set.

utf8.c

diff --git a/utf8.c b/utf8.c
index 1cd191d..9619da7 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -1304,8 +1304,11 @@ Perl_utf8n_to_uvchr_error(pTHX_ const U8 *s,
     /* Here, we have found all the possible problems, except for when the input
      * is for a problematic code point not allowed by the input parameters. */
 
-                                              /* isn't problematic if < this */
-    if (   (   (   LIKELY(! possible_problems) && uv >= UNICODE_SURROGATE_FIRST)
+                                /* uv is valid for overlongs */
+    if (   (   (      LIKELY(! (possible_problems & ~UTF8_GOT_LONG))
+
+                      /* isn't problematic if < this */
+                   && uv >= UNICODE_SURROGATE_FIRST)
             || (   UNLIKELY(possible_problems)
 
                           /* if overflow, we know without looking further