This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
S_share_hek_flags can revert to returning a HEK
authorNicholas Clark <nick@ccl4.org>
Mon, 13 Jun 2005 09:43:18 +0000 (09:43 +0000)
committerNicholas Clark <nick@ccl4.org>
Mon, 13 Jun 2005 09:43:18 +0000 (09:43 +0000)
p4raw-id: //depot/perl@24819

embed.fnc
hv.c
proto.h

index 7262eeb..baa3312 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -998,7 +998,7 @@ s   |void   |del_he         |NN HE *p
 sR     |HEK*   |save_hek_flags |NN const char *str|I32 len|U32 hash|int flags
 s      |void   |hv_magic_check |NN HV *hv|NN bool *needs_copy|NN bool *needs_store
 s      |void   |unshare_hek_or_pvn|const HEK* hek|const char* str|I32 len|U32 hash
-sR     |HE   |share_hek_flags|const char* sv|I32 len|U32 hash|int flags
+sR     |HEK*   |share_hek_flags|const char* sv|I32 len|U32 hash|int flags
 rs     |void   |hv_notallowed  |int flags|NN const char *key|I32 klen|NN const char *msg
 s      |struct xpvhv_aux*|hv_auxinit|HV *hv
 #endif
diff --git a/hv.c b/hv.c
index 68a9597..3d2e589 100644 (file)
--- a/hv.c
+++ b/hv.c
@@ -135,8 +135,8 @@ Perl_hek_dup(pTHX_ HEK *source, CLONE_PARAMS* param)
     }
     else {
        shared
-           = HeKEY_hek(share_hek_flags(HEK_KEY(source), HEK_LEN(source),
-                                       HEK_HASH(source), HEK_FLAGS(source)));
+           = share_hek_flags(HEK_KEY(source), HEK_LEN(source),
+                             HEK_HASH(source), HEK_FLAGS(source));
        ptr_table_store(PL_ptr_table, source, shared);
     }
     return shared;
@@ -177,9 +177,8 @@ Perl_he_dup(pTHX_ HE *e, bool shared, CLONE_PARAMS* param)
        }
        else {
            shared
-               = HeKEY_hek(share_hek_flags(HEK_KEY(source), HEK_LEN(source),
-                                           HEK_HASH(source),
-                                           HEK_FLAGS(source)));
+               = share_hek_flags(HEK_KEY(source), HEK_LEN(source),
+                                 HEK_HASH(source), HEK_FLAGS(source));
            ptr_table_store(PL_ptr_table, source, shared);
        }
        HeKEY_hek(ret) = shared;
@@ -688,8 +687,8 @@ S_hv_fetch_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
                    /* Need to swap the key we have for a key with the flags we
                       need. As keys are shared we can't just write to the
                       flag, so we share the new one, unshare the old one.  */
-                   HEK *new_hek = HeKEY_hek(share_hek_flags(key, klen, hash,
-                                                            masked_flags));
+                   HEK *new_hek = share_hek_flags(key, klen, hash,
+                                                  masked_flags);
                    unshare_hek (HeKEY_hek(entry));
                    HeKEY_hek(entry) = new_hek;
                }
@@ -793,7 +792,7 @@ S_hv_fetch_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
     /* share_hek_flags will do the free for us.  This might be considered
        bad API design.  */
     if (HvSHAREKEYS(hv))
-       HeKEY_hek(entry) = HeKEY_hek(share_hek_flags(key, klen, hash, flags));
+       HeKEY_hek(entry) = share_hek_flags(key, klen, hash, flags);
     else                                       /* gotta do the real thing */
        HeKEY_hek(entry) = save_hek_flags(key, klen, hash, flags);
     HeVAL(entry) = val;
@@ -1420,7 +1419,7 @@ Perl_newHVhv(pTHX_ HV *ohv)
                ent = new_HE();
                HeVAL(ent)     = newSVsv(HeVAL(oent));
                HeKEY_hek(ent)
-                    = shared ? HeKEY_hek(share_hek_flags(key, len, hash, flags))
+                    = shared ? share_hek_flags(key, len, hash, flags)
                              :  save_hek_flags(key, len, hash, flags);
                if (prev)
                    HeNEXT(prev) = ent;
@@ -2279,10 +2278,10 @@ Perl_share_hek(pTHX_ const char *str, I32 len, register U32 hash)
           flags |= HVhek_WASUTF8 | HVhek_FREEKEY;
     }
 
-    return HeKEY_hek(share_hek_flags (str, len, hash, flags));
+    return share_hek_flags (str, len, hash, flags);
 }
 
-STATIC HE *
+STATIC HEK *
 S_share_hek_flags(pTHX_ const char *str, I32 len, register U32 hash, int flags)
 {
     register XPVHV* xhv;
@@ -2363,7 +2362,7 @@ S_share_hek_flags(pTHX_ const char *str, I32 len, register U32 hash, int flags)
     if (flags & HVhek_FREEKEY)
        Safefree(str);
 
-    return entry;
+    return HeKEY_hek(entry);
 }
 
 I32 *
diff --git a/proto.h b/proto.h
index 499f106..57c3826 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -1875,7 +1875,7 @@ STATIC void       S_hv_magic_check(pTHX_ HV *hv, bool *needs_copy, bool *needs_store)
                        __attribute__nonnull__(pTHX_3);
 
 STATIC void    S_unshare_hek_or_pvn(pTHX_ const HEK* hek, const char* str, I32 len, U32 hash);
-STATIC HE    S_share_hek_flags(pTHX_ const char* sv, I32 len, U32 hash, int flags)
+STATIC HEK*    S_share_hek_flags(pTHX_ const char* sv, I32 len, U32 hash, int flags)
                        __attribute__warn_unused_result__;
 
 STATIC void    S_hv_notallowed(pTHX_ int flags, const char *key, I32 klen, const char *msg)