From a4e0d2399ad31e76c4f1f1f5c7e44c6b5df4e6ae Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Sun, 8 Oct 2006 00:25:07 +0000 Subject: [PATCH] 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 --- ext/Data/Dumper/Dumper.xs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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)) -- 2.7.4