In S_pending_ident(), only call gv_fetchpvn_flags() if the warning is enabled.
Nicholas Clark [Sat, 24 Oct 2009 11:57:18 +0000 (12:57 +0100)]
ckWARN(WARN_AMBIGUOUS) is cheaper than Perl_gv_fetchpvn_flags().

toke.c

diff --git a/toke.c b/toke.c
index e1f98dc..8c019c5 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -7129,7 +7129,8 @@ S_pending_ident(pTHX)
        and @foo isn't a variable we can find in the symbol
        table.
     */
-    if (pit == '@' && PL_lex_state != LEX_NORMAL && !PL_lex_brackets) {
+    if (ckWARN(WARN_AMBIGUOUS) &&
+       pit == '@' && PL_lex_state != LEX_NORMAL && !PL_lex_brackets) {
         GV *const gv = gv_fetchpvn_flags(PL_tokenbuf + 1, tokenbuf_len - 1, 0,
                                         SVt_PVAV);
         if ((!gv || ((PL_tokenbuf[0] == '@') ? !GvAV(gv) : !GvHV(gv)))
@@ -7139,9 +7140,9 @@ S_pending_ident(pTHX)
           )
         {
             /* Downgraded from fatal to warning 20000522 mjd */
-            Perl_ck_warner(aTHX_ packWARN(WARN_AMBIGUOUS),
-                          "Possible unintended interpolation of %s in string",
-                          PL_tokenbuf);
+            Perl_warner(aTHX_ packWARN(WARN_AMBIGUOUS),
+                       "Possible unintended interpolation of %s in string",
+                       PL_tokenbuf);
         }
     }