diff options
author | Perl 5 Porters <perl5-porters@africa.nicoh.com> | 1996-09-05 02:52:21 -0400 |
---|---|---|
committer | Andy Dougherty <doughera@lafcol.lafayette.edu> | 1996-09-05 02:52:21 -0400 |
commit | effa1e2ddfeaa0d3577f49b2ffc9a13dbf31279f (patch) | |
tree | 45a592c4aec2bae746faa0776ef00bb88c80b2d1 /hv.c | |
parent | 77c65e92af20c99e482a4ce915adf21d0d3e4ffa (diff) | |
download | perl-effa1e2ddfeaa0d3577f49b2ffc9a13dbf31279f.tar.gz |
perl 5.003_05: hv.c
Date: Thu, 05 Sep 1996 00:25:28 -0400
From: Gurusamy Sarathy <gsar@engin.umich.edu>
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 <gsar@engin.umich.edu>
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
Diffstat (limited to 'hv.c')
-rw-r--r-- | hv.c | 19 |
1 files changed, 12 insertions, 7 deletions
@@ -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; |