On Mon, Nov 03, 2003 at 08:27:39PM -0800, Ilya Zakharevich wrote: > I do not know whether the fact that an operation is an order of magnitude > slower than it must be should be considered a bug... > > This patch speeds up rounding-to-integer (which is "%.0f") about 15x, > and g-format sprintf() about 1.5x. Actually, this version had a buffer overrun (due to cut & paste from a place where buffer was correctly prepared) possibility. --- ./sv.c-ppre Mon Nov 3 20:00:42 2003 +++ ./sv.c Mon Nov 3 20:53:44 2003 @@ -8354,10 +8354,12 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const cha else return; if (*pp == 'g') { - Gconvert((double)nv, (digits ? digits : 1), 0, ebuf); - sv_catpv(sv, ebuf); - if (*ebuf) /* May return an empty string for digits==0 */ - return; + if (digits < sizeof(ebuf) - NV_DIG - 10) { /* 0, point, slack */ + Gconvert((double)nv, digits, 0, ebuf); + sv_catpv(sv, ebuf); + if (*ebuf) /* May return an empty string for digits==0 */ + return; + } } else if (!digits) { STRLEN l;Thread Previous | Thread Next