diff options
author | Nicholas Clark <nick@ccl4.org> | 2002-08-19 00:17:01 +0100 |
---|---|---|
committer | hv <hv@crypt.org> | 2002-08-20 14:07:56 +0000 |
commit | 46187eeb6d9336144ec364973ed57177c89816cf (patch) | |
tree | 476bf6483bf8a7a30003c193ed84a916e42af83c /hv.c | |
parent | 30e7fb8a3219c29103ee46480c5ed6162f1ce92b (diff) | |
download | perl-46187eeb6d9336144ec364973ed57177c89816cf.tar.gz |
Clean up copy-on-write macros and debug facilities (new flag 'C').
Handle CoW in hashes:
Subject: Re: why would tr/// be performing hash copies?
Message-id: <20020818221700.GD294@Bagpuss.unfortu.net>
p4raw-id: //depot/perl@17740
Diffstat (limited to 'hv.c')
-rw-r--r-- | hv.c | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -409,8 +409,13 @@ Perl_hv_fetch_ent(pTHX_ HV *hv, SV *keysv, I32 lval, register U32 hash) flags |= HVhek_WASUTF8 | HVhek_FREEKEY; } - if (!hash) - PERL_HASH(hash, key, klen); + if (!hash) { + if SvIsCOW_shared_hash(keysv) { + hash = SvUVX(keysv); + } else { + PERL_HASH(hash, key, klen); + } + } /* entry = (HvARRAY(hv))[hash & (I32) HvMAX(hv)]; */ entry = ((HE**)xhv->xhv_array)[hash & (I32) xhv->xhv_max]; @@ -737,8 +742,13 @@ Perl_hv_store_ent(pTHX_ HV *hv, SV *keysv, SV *val, U32 hash) HvHASKFLAGS_on((SV*)hv); } - if (!hash) - PERL_HASH(hash, key, klen); + if (!hash) { + if SvIsCOW_shared_hash(keysv) { + hash = SvUVX(keysv); + } else { + PERL_HASH(hash, key, klen); + } + } if (!xhv->xhv_array /* !HvARRAY(hv) */) Newz(505, xhv->xhv_array /* HvARRAY(hv) */, |