This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
utf8.c: Add some UNLIKELY()
authorKarl Williamson <khw@cpan.org>
Tue, 8 Dec 2015 18:08:51 +0000 (11:08 -0700)
committerKarl Williamson <khw@cpan.org>
Wed, 9 Dec 2015 02:01:28 +0000 (19:01 -0700)
utf8.c

diff --git a/utf8.c b/utf8.c
index 722a7bf..f2b97ed 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -120,7 +120,7 @@ Perl_uvoffuni_to_utf8_flags(pTHX_ U8 *d, UV uv, UV flags)
 
     /* The first problematic code point is the first surrogate */
     if (uv >= UNICODE_SURROGATE_FIRST) {
-       if (UNICODE_IS_SURROGATE(uv)) {
+       if (UNLIKELY(UNICODE_IS_SURROGATE(uv))) {
            if (flags & UNICODE_WARN_SURROGATE) {
                Perl_ck_warner_d(aTHX_ packWARN(WARN_SURROGATE),
                                            "UTF-16 surrogate U+%04"UVXf, uv);
@@ -129,7 +129,7 @@ Perl_uvoffuni_to_utf8_flags(pTHX_ U8 *d, UV uv, UV flags)
                return NULL;
            }
        }
-       else if (UNICODE_IS_SUPER(uv)) {
+       else if (UNLIKELY(UNICODE_IS_SUPER(uv))) {
             if (   UNLIKELY(uv > MAX_NON_DEPRECATED_CP)
                 && ckWARN_d(WARN_DEPRECATED))
             {
@@ -153,7 +153,7 @@ Perl_uvoffuni_to_utf8_flags(pTHX_ U8 *d, UV uv, UV flags)
                return NULL;
            }
        }
-       else if (UNICODE_IS_NONCHAR(uv)) {
+       else if (UNLIKELY(UNICODE_IS_NONCHAR(uv))) {
            if (flags & UNICODE_WARN_NONCHAR) {
                Perl_ck_warner_d(aTHX_ packWARN(WARN_NONCHAR),
                 "Unicode non-character U+%04"UVXf" is not recommended for open interchange",