diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-11-06 14:04:51 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-11-06 14:23:49 -0800 |
commit | 0abcdfa4c5da571f9a31d50e4a121867868e8aaf (patch) | |
tree | 69628a02e27d839663e8073694d0c9a88a782905 /toke.c | |
parent | bc344123285ead072c87437a15e486ff36fef609 (diff) | |
download | perl-0abcdfa4c5da571f9a31d50e4a121867868e8aaf.tar.gz |
Avoid redundant copies in string evals
Perl_lex_start copies the string passed to it unconditionally.
Sometimes pp_entereval makes a copy before passing the string
to lex_start. So in those cases we can pass a flag to avoid a
redundant copy.
Diffstat (limited to 'toke.c')
-rw-r--r-- | toke.c | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -726,16 +726,13 @@ Perl_lex_start(pTHX_ SV *line, PerlIO *rsfp, U32 flags) if (line) { s = SvPV_const(line, len); - } else { - len = 0; - } - - if (!len) { - parser->linestr = newSVpvs("\n;"); - } else { - parser->linestr = newSVpvn_flags(s, len, SvUTF8(line)); + parser->linestr = flags & LEX_START_COPIED + ? SvREFCNT_inc_simple_NN(line) + : newSVpvn_flags(s, len, SvUTF8(line)); if (s[len-1] != ';') sv_catpvs(parser->linestr, "\n;"); + } else { + parser->linestr = newSVpvs("\n;"); } parser->oldoldbufptr = parser->oldbufptr = |