Don’t create an AV for unfiltered code
authorFather Chrysostomos <sprout@cpan.org>
Sat, 19 Nov 2011 04:27:15 +0000 (20:27 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 19 Nov 2011 04:27:15 +0000 (20:27 -0800)
When there are no source filters, we don’t need to create an AV to
hold them.  The code for adding a filter already does a null check.

toke.c

diff --git a/toke.c b/toke.c
index 33d7b86..8690877 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -715,8 +715,12 @@ Perl_lex_start(pTHX_ SV *line, PerlIO *rsfp, U32 flags)
     parser->rsfp = rsfp;
     parser->rsfp_filters =
       !(flags & LEX_START_SAME_FILTER) || !oparser
-        ? newAV()
-        : MUTABLE_AV(SvREFCNT_inc(oparser->rsfp_filters));
+        ? NULL
+        : MUTABLE_AV(SvREFCNT_inc(
+            oparser->rsfp_filters
+             ? oparser->rsfp_filters
+             : (oparser->rsfp_filters = newAV())
+          ));
 
     Newx(parser->lex_brackstack, 120, char);
     Newx(parser->lex_casestack, 12, char);