This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Yves said that the XS version of Data::Dumper was inefficient because
authorNicholas Clark <nick@ccl4.org>
Sat, 7 Oct 2006 23:42:56 +0000 (23:42 +0000)
committerNicholas Clark <nick@ccl4.org>
Sat, 7 Oct 2006 23:42:56 +0000 (23:42 +0000)
commit9fa5cce2ac5fe91228c7c54739f581c98f0738ef
tree0f8c3a2f7b804da153d1454b6836b9f974389a8a
parent0ca9e7c5f00427e141fad33150dcf6f077317af1
Yves said that the XS version of Data::Dumper was inefficient because
it keeps triggering realloc() due to sv_cat(). Here's a rather brute
force approach to pre-stretching the buffer - if there are less than
40 bytes free, grow it by 50%.

Surprisingly effective for my test program
./perl -Ilib -MData::Dumper -MStorable=retrieve -we \
    'print Dumper(retrieve(shift))' ~/.cpan/Metadata >/dev/null

Before
real    2m42.921s
user    1m43.321s
sys     0m55.611s

After
real    0m5.205s
user    0m4.885s
sys     0m0.255s

Same 25M of output, byte for byte. :-)

p4raw-id: //depot/perl@28963
ext/Data/Dumper/Dumper.xs