From: Nicholas Clark Date: Sun, 8 Oct 2006 00:25:07 +0000 (+0000) Subject: Document the growth policy, and Yves suggested a better arbitary X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a4e0d2399ad31e76c4f1f1f5c7e44c6b5df4e6ae;p=p5sagit%2Fp5-mst-13.2.git Document the growth policy, and Yves suggested a better arbitary constant. (The original plan was add 80 if free space is less than 80, which wasn't a noticable improvement. Hence 40 was 80/2 for plan B) p4raw-id: //depot/perl@28964 --- diff --git a/ext/Data/Dumper/Dumper.xs b/ext/Data/Dumper/Dumper.xs index dbdc2d6..0e60f6f 100644 --- a/ext/Data/Dumper/Dumper.xs +++ b/ext/Data/Dumper/Dumper.xs @@ -274,9 +274,14 @@ DD_dump(pTHX_ SV *val, const char *name, STRLEN namelen, SV *retval, HV *seenhv, if (!val) return 0; - if (SvTYPE(retval) >= SVt_PV && (SvLEN(retval) - SvCUR(retval)) < 40) { + /* If the ouput buffer has less than some arbitary amount of space + remaining, then enlarge it. For the test case (25M of output), + *1.1 was slower, *2.0 was the same, so the first guess of 1.5 is + deemed to be good enough. */ + if (SvTYPE(retval) >= SVt_PV && (SvLEN(retval) - SvCUR(retval)) < 42) { sv_grow(retval, SvCUR(retval) * 1.5); } + realtype = SvTYPE(val); if (SvGMAGICAL(val))