summaryrefslogtreecommitdiff
path: root/hv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2002-08-19 00:17:01 +0100
committerhv <hv@crypt.org>2002-08-20 14:07:56 +0000
commit46187eeb6d9336144ec364973ed57177c89816cf (patch)
tree476bf6483bf8a7a30003c193ed84a916e42af83c /hv.c
parent30e7fb8a3219c29103ee46480c5ed6162f1ce92b (diff)
downloadperl-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.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/hv.c b/hv.c
index 6d8461fe39..0d087676c5 100644
--- a/hv.c
+++ b/hv.c
@@ -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) */,