From: Spider Boardman Date: Mon, 30 Sep 1996 05:13:28 +0000 (-0400) Subject: Re: pre extending hash? - need speed X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=69969c6f8dad38fedd2ed2c653a7948030e5ecf8;p=p5sagit%2Fp5-mst-13.2.git Re: pre extending hash? - need speed Restore the 5.003 gv_fullname() and gv_efullname() functions. Provide new 3-arg forms gv_fullname3() and gv_efullname3(). The patch below (which is relative to perl5.001l) implements "keys %hash = 50_000;" (or other integer-evaluable sizes) for pre-sizing hashes. I've only moved the patch forward from when I first did it. I'm sure the code in hv_ksplit could be improved. --- diff --git a/op.c b/op.c index b992fde..d3b0344 100644 --- a/op.c +++ b/op.c @@ -49,7 +49,7 @@ CvNAME(cv) CV* cv; { SV* tmpsv = sv_newmortal(); - gv_efullname(tmpsv, CvGV(cv), Nullch); + gv_efullname3(tmpsv, CvGV(cv), Nullch); return SvPV(tmpsv,na); } @@ -1010,6 +1010,11 @@ I32 type; case OP_PUSHMARK: break; + case OP_KEYS: + if (type != OP_SASSIGN) + goto nomod; + mtype = 'k'; + goto makelv; case OP_POS: mtype = '.'; goto makelv; @@ -2977,7 +2982,7 @@ OP *block; sv_catpv(sv,"-"); sprintf(buf,"%ld",(long)curcop->cop_line); sv_catpv(sv,buf); - gv_efullname(tmpstr, gv, Nullch); + gv_efullname3(tmpstr, gv, Nullch); hv_store(GvHV(DBsub), SvPVX(tmpstr), SvCUR(tmpstr), sv, 0); } op_free(op);