From: Perl 5 Porters Date: Thu, 5 Sep 1996 06:52:21 +0000 (-0400) Subject: perl 5.003_05: hv.c X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=effa1e2ddfeaa0d3577f49b2ffc9a13dbf31279f;p=p5sagit%2Fp5-mst-13.2.git perl 5.003_05: hv.c Date: Thu, 05 Sep 1996 00:25:28 -0400 From: Gurusamy Sarathy Subject: minor misc. cleanup This patch makes some minor cleanups to the sources. No change in functionality whatsoever. Date: Thu, 05 Sep 1996 02:52:21 -0400 From: Gurusamy Sarathy Subject: debugger problems--another patch (was Re: 5.003_04) I have tried to avoid copying of hash keys that are passed to magical hashes, but it seems that copying may be unavoidable since the hv_*_ent() functions could be PADTMPs (and other SVs that may get reused) as keys. VMS dynamic %ENV fix --- diff --git a/hv.c b/hv.c index b77e44e..6dfa9b1 100644 --- a/hv.c +++ b/hv.c @@ -142,10 +142,9 @@ register U32 hash; if (!hv) return 0; - xhv = (XPVHV*)SvANY(hv); - if (SvRMAGICAL(hv) && mg_find((SV*)hv,'P')) { sv = sv_newmortal(); + keysv = sv_2mortal(newSVsv(keysv)); mg_copy((SV*)hv, sv, (char*)keysv, HEf_SVKEY); entry = &He; HeVAL(entry) = sv; @@ -154,11 +153,7 @@ register U32 hash; return entry; } - key = SvPV(keysv, klen); - - if (!hash) - PERL_HASH(hash, key, klen); - + xhv = (XPVHV*)SvANY(hv); if (!xhv->xhv_array) { if (lval #ifdef DYNAMIC_ENV_FETCH /* if it's an %ENV lookup, we may get it on the fly */ @@ -170,6 +165,11 @@ register U32 hash; return 0; } + key = SvPV(keysv, klen); + + if (!hash) + PERL_HASH(hash, key, klen); + entry = ((HE**)xhv->xhv_array)[hash & (I32) xhv->xhv_max]; for (; entry; entry = HeNEXT(entry)) { if (HeHASH(entry) != hash) /* strings can't be equal */ @@ -287,6 +287,7 @@ register U32 hash; xhv = (XPVHV*)SvANY(hv); if (SvMAGICAL(hv)) { + keysv = sv_2mortal(newSVsv(keysv)); mg_copy((SV*)hv, val, (char*)keysv, HEf_SVKEY); #ifndef OVERLOAD if (!xhv->xhv_array) @@ -525,6 +526,7 @@ U32 hash; if (SvRMAGICAL(hv)) { if (mg_find((SV*)hv,'P')) { sv = sv_newmortal(); + keysv = sv_2mortal(newSVsv(keysv)); mg_copy((SV*)hv, sv, (char*)keysv, HEf_SVKEY); magic_existspack(sv, mg_find(sv, 'p')); return SvTRUE(sv); @@ -755,6 +757,9 @@ HV *hv; { register XPVHV* xhv = (XPVHV*)SvANY(hv); HE *entry = xhv->xhv_eiter; +#ifdef DYNAMIC_ENV_FETCH /* set up %ENV for iteration */ + if (HvNAME(hv) && strEQ(HvNAME(hv),ENV_HV_NAME)) prime_env_iter(); +#endif if (entry && HeKLEN(entry) == HEf_LAZYDEL) /* was deleted earlier? */ he_free(entry, HvSHAREKEYS(hv)); xhv->xhv_riter = -1;