This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make eval "s//<<END/e" slightly faster
authorFather Chrysostomos <sprout@cpan.org>
Wed, 29 Aug 2012 20:10:01 +0000 (13:10 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 31 Aug 2012 01:18:08 +0000 (18:18 -0700)
commitf20c3a2bbc5915fc17f30c1fc6e9e811fa7ccafa
tree1ea0adb171dcb704c259241632583faf94a0270a
parent7d66e4bd750064b354bdc26d4e38be5956b64d22
Make eval "s//<<END/e" slightly faster

The code that peeks into an outer linestr buffer to find the heredoc
body has to modify that buffer and remove the heredoc body from it.

It copies the text after the quote-like operator up to the end of the
line into a new SV, concatenates the text after the heredoc body into
a new SV, and then copies it back to linestr right after the quote-
like operator.

So, in this example:

eval "s//<<END/e; # jiggles\nfoo\nEND\ndie;"

It ends up copying this:

               "; # jiggles\ndie;\n;"

into this at the position shown:

eval "s//<<END/e; # jiggles\nfoo\nEND\ndie;\n;"
                ^

There is no need for two copies.  And there is no need to copy the
rest of the line where the heredoc marker is.
toke.c