This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
toke.c: Don't compare same bytes twice
authorKarl Williamson <khw@cpan.org>
Mon, 13 Feb 2017 18:31:53 +0000 (11:31 -0700)
committerKarl Williamson <khw@cpan.org>
Tue, 14 Feb 2017 04:24:08 +0000 (21:24 -0700)
Before starting this memEQ, we know that the first bytes are the same,
so might as well start the compare with the 2nd bytes.

toke.c

diff --git a/toke.c b/toke.c
index b0880b9..b37052e 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -10546,7 +10546,8 @@ S_scan_str(pTHX_ char *start, int keep_bracketed_quoted, int keep_delims, int re
                else if (*s == term) {
                    if (termlen == 1)
                        break;
-                   if (s+termlen <= PL_bufend && memEQ(s, (char*)termstr, termlen))
+                    if (   s + termlen <= PL_bufend
+                        && memEQ(s + 1, (char*)termstr + 1, termlen - 1))
                     {
                         if (   check_grapheme
                             && UNLIKELY(! _is_grapheme((U8 *) start,