diff options
author | Spider Boardman <spider@Orb.Nashua.NH.US> | 1996-09-30 01:13:28 -0400 |
---|---|---|
committer | Andy Dougherty <doughera@lafcol.lafayette.edu> | 1996-09-30 01:13:28 -0400 |
commit | 85581909df34d9ffca6c85cafeb2595c4cb89ffb (patch) | |
tree | 0dc96a7001ca20413c51a5bfb0afee40b5defd09 | |
parent | edc7bc4959621ea7da76262c92da0b8af51b93fe (diff) | |
download | perl-85581909df34d9ffca6c85cafeb2595c4cb89ffb.tar.gz |
Re: pre extending hash? - need speed
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.
-rw-r--r-- | doop.c | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -629,8 +629,15 @@ dARGS if (op->op_type == OP_RV2HV || op->op_type == OP_PADHV) dokeys = dovalues = TRUE; - if (!hv) + if (!hv) { + if (op->op_flags & OPf_MOD) { /* lvalue */ + dTARGET; /* make sure to clear its target here */ + if (SvTYPE(TARG) == SVt_PVLV) + LvTARG(TARG) = Nullsv; + PUSHs(TARG); + } RETURN; + } (void)hv_iterinit(hv); /* always reset iterator regardless */ @@ -638,6 +645,17 @@ dARGS I32 i; dTARGET; + if (op->op_flags & OPf_MOD) { /* lvalue */ + if (SvTYPE(TARG) < SVt_PVLV) { + sv_upgrade(TARG, SVt_PVLV); + sv_magic(TARG, Nullsv, 'k', Nullch, 0); + } + LvTYPE(TARG) = 'k'; + LvTARG(TARG) = (SV*)hv; + PUSHs(TARG); + RETURN; + } + if (!SvRMAGICAL(hv) || !mg_find((SV*)hv,'P')) i = HvKEYS(hv); else { |