This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pp_formline: simplify growing of PL_formtarget
authorDavid Mitchell <davem@iabyn.com>
Sat, 4 Feb 2017 15:54:09 +0000 (15:54 +0000)
committerDavid Mitchell <davem@iabyn.com>
Sat, 4 Feb 2017 16:03:17 +0000 (16:03 +0000)
commit90c3aa01208e3c5b9ab464a058bbd2f6ebda4ff4
tree373a937ecdab4101d4a2edd697b526cb3eaf689e
parente452bf1c9e9f30813b1f289188a6e8b0894575ba
pp_formline: simplify growing of PL_formtarget

There's some reasonably complex logic to try and second guess how much
space to allocate or reallocate for the output buffer (some of which is
my doing from 2011, 26e935cfa6e7).

This commit removes most of this and now just does:

initially, grow the buffer by the size of the format. If any further
growing is needed later on (e.g. after a utf8 upgrade or due to @*) then
just grow as needed. This may give less optimal growing in edge cases
( i.e. repeated smaller grows rather than one big grow), but the old code
was often guessing wrong anyway.

This commit also makes it *always* check whether PL_formtarget needs growing
when about to append data to it, which is safer.
pp_ctl.c