This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Abstract all access to the shared hash value through SvSHARED_HASH()
authorNicholas Clark <nick@ccl4.org>
Mon, 6 Jun 2005 14:50:21 +0000 (14:50 +0000)
committerNicholas Clark <nick@ccl4.org>
Mon, 6 Jun 2005 14:50:21 +0000 (14:50 +0000)
p4raw-id: //depot/perl@24716

hv.c
pp_hot.c
sv.c
sv.h

diff --git a/hv.c b/hv.c
index 6201e66..f1e80a9 100644 (file)
--- a/hv.c
+++ b/hv.c
@@ -650,7 +650,7 @@ S_hv_fetch_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
        flags |= HVhek_REHASH;
     } else if (!hash) {
         if (keysv && (SvIsCOW_shared_hash(keysv))) {
-            hash = SvUVX(keysv);
+            hash = SvSHARED_HASH(keysv);
         } else {
             PERL_HASH(hash, key, klen);
         }
@@ -1014,7 +1014,7 @@ S_hv_delete_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
        PERL_HASH_INTERNAL(hash, key, klen);
     } else if (!hash) {
         if (keysv && (SvIsCOW_shared_hash(keysv))) {
-            hash = SvUVX(keysv);
+            hash = SvSHARED_HASH(keysv);
         } else {
             PERL_HASH(hash, key, klen);
         }
index e41d4f2..e426698 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1665,7 +1665,7 @@ PP(pp_helem)
     const U32 lval = PL_op->op_flags & OPf_MOD || LVRET;
     const U32 defer = PL_op->op_private & OPpLVAL_DEFER;
     SV *sv;
-    const U32 hash = (SvIsCOW_shared_hash(keysv)) ? SvUVX(keysv) : 0;
+    const U32 hash = (SvIsCOW_shared_hash(keysv)) ? SvSHARED_HASH(keysv) : 0;
     I32 preeminent = 0;
 
     if (SvTYPE(hv) == SVt_PVHV) {
@@ -2960,7 +2960,7 @@ PP(pp_method_named)
 {
     dSP;
     SV* sv = cSVOP_sv;
-    U32 hash = SvUVX(sv);
+    U32 hash = SvSHARED_HASH(sv);
 
     XPUSHs(method_common(sv, &hash));
     RETURN;
diff --git a/sv.c b/sv.c
index dd2c876..16aac13 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -4521,7 +4521,7 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV *sstr, I32 flags)
 #endif
                {
                     /* SvIsCOW_shared_hash */
-                    UV hash = SvUVX(sstr);
+                    UV hash = SvSHARED_HASH(sstr);
                     DEBUG_C(PerlIO_printf(Perl_debug_log,
                                           "Copy on write: Sharing hash\n"));
                     SvPV_set(dstr,
@@ -4665,7 +4665,7 @@ Perl_sv_setsv_cow(pTHX_ SV *dstr, SV *sstr)
 
        if (SvLEN(sstr) == 0) {
            /* source is a COW shared hash key.  */
-           UV hash = SvUVX(sstr);
+           UV hash = SvSHARED_HASH(sstr);
            DEBUG_C(PerlIO_printf(Perl_debug_log,
                                  "Fast copy on write: Sharing hash\n"));
            SvUV_set(dstr, hash);
@@ -4921,7 +4921,7 @@ Perl_sv_force_normal_flags(pTHX_ register SV *sv, U32 flags)
             const char *pvx = SvPVX_const(sv);
             STRLEN len = SvLEN(sv);
             STRLEN cur = SvCUR(sv);
-            U32 hash = SvUVX(sv);
+            U32 hash = SvSHARED_HASH(sv);
             SV *next = SV_COW_NEXT_SV(sv);   /* next COW sv in the loop. */
             if (DEBUG_C_TEST) {
                 PerlIO_printf(Perl_debug_log,
@@ -4958,7 +4958,7 @@ Perl_sv_force_normal_flags(pTHX_ register SV *sv, U32 flags)
            const char *pvx = SvPVX_const(sv);
            const int is_utf8 = SvUTF8(sv);
            STRLEN len = SvCUR(sv);
-            U32 hash   = SvUVX(sv);
+            U32 hash   = SvSHARED_HASH(sv);
            SvFAKE_off(sv);
            SvREADONLY_off(sv);
             SvPV_set(sv, (char*)0);
diff --git a/sv.h b/sv.h
index 15d90a9..da03ca8 100644 (file)
--- a/sv.h
+++ b/sv.h
@@ -1309,6 +1309,8 @@ Like C<sv_catsv> but doesn't process magic.
                                    (SVf_FAKE | SVf_READONLY))
 #define SvIsCOW_shared_hash(sv)        (SvIsCOW(sv) && SvLEN(sv) == 0)
 
+#define SvSHARED_HASH(sv) SvUVX(sv)
+
 /* flag values for sv_*_flags functions */
 #define SV_IMMEDIATE_UNREF     1
 #define SV_GMAGIC              2