This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
toke.c: Save a branch
authorKarl Williamson <khw@cpan.org>
Thu, 19 Jan 2017 20:52:57 +0000 (13:52 -0700)
committerKarl Williamson <khw@cpan.org>
Thu, 19 Jan 2017 21:42:08 +0000 (14:42 -0700)
By ordering these sequential tests properly, a branch in the mainline
can be saved.

toke.c

diff --git a/toke.c b/toke.c
index 9700d35..5f8a76f 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -3202,10 +3202,12 @@ S_scan_const(pTHX_ char *start)
                 if (real_range_max) {
                     *d++ = (char) UTF8_TWO_BYTE_HI(0x100);
                     *d++ = (char) UTF8_TWO_BYTE_LO(0x100);
                 if (real_range_max) {
                     *d++ = (char) UTF8_TWO_BYTE_HI(0x100);
                     *d++ = (char) UTF8_TWO_BYTE_LO(0x100);
-                    if (real_range_max > 0x101)
-                        *d++ = (char) ILLEGAL_UTF8_BYTE;
-                    if (real_range_max > 0x100)
+                    if (real_range_max > 0x100) {
+                        if (real_range_max > 0x101) {
+                            *d++ = (char) ILLEGAL_UTF8_BYTE;
+                        }
                         d = (char*)uvchr_to_utf8((U8*)d, real_range_max);
                         d = (char*)uvchr_to_utf8((U8*)d, real_range_max);
+                    }
                 }
 #endif
 
                 }
 #endif