This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
toke.c: Use strpbrk instead of sequential strchr()
authorKarl Williamson <khw@cpan.org>
Tue, 6 Dec 2016 17:16:10 +0000 (10:16 -0700)
committerKarl Williamson <khw@cpan.org>
Sun, 11 Dec 2016 21:33:46 +0000 (14:33 -0700)
    strpbrk("ABC")

does the same thing (faster) as

    strchr('A') || strchr('B') || strchr('C')

toke.c

diff --git a/toke.c b/toke.c
index 4ba7337..cd01255 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -4634,9 +4634,7 @@ Perl_yylex(pTHX)
                 if (strnEQ(s, "L\\u", 3) || strnEQ(s, "U\\l", 3))
                     tmp = *s, *s = s[2], s[2] = (char)tmp;     /* misordered... */
                if ((*s == 'L' || *s == 'U' || *s == 'F')
-                    && (strchr(PL_lex_casestack, 'L')
-                        || strchr(PL_lex_casestack, 'U')
-                        || strchr(PL_lex_casestack, 'F')))
+                    && (strpbrk(PL_lex_casestack, "LUF")))
                 {
                    PL_lex_casestack[--PL_lex_casemods] = '\0';
                    PL_lex_allbrackets--;