This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
toke.c: Avoid work if tr/a-b/foo/
authorKarl Williamson <khw@cpan.org>
Wed, 18 Jan 2017 22:36:49 +0000 (15:36 -0700)
committerKarl Williamson <khw@cpan.org>
Thu, 19 Jan 2017 21:42:08 +0000 (14:42 -0700)
A two-element range here is already fully set up, and no need to do
anything.

toke.c

diff --git a/toke.c b/toke.c
index 8409bb6..b54b368 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -3092,6 +3092,14 @@ S_scan_const(pTHX_ char *start)
                     }
                 }
 
+                /* If the range is exactly two code points long, they are
+                 * already both in the output */
+                if (UNLIKELY(range_min + 1 == range_max)) {
+                    goto range_done;
+                }
+
+                /* Here the range contains at least 3 code points */
+
                if (has_utf8) {
 
                     /* If everything in the transliteration is below 256, we