This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove the MANIFEST from Compress-Raw-Bzip2
[perl5.git] / hv.c
diff --git a/hv.c b/hv.c
index f0572f3..79f5973 100644 (file)
--- a/hv.c
+++ b/hv.c
@@ -388,8 +388,12 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
        if (flags & HVhek_FREEKEY)
            Safefree(key);
        key = SvPV_const(keysv, klen);
-       flags = 0;
        is_utf8 = (SvUTF8(keysv) != 0);
+       if (SvIsCOW_shared_hash(keysv)) {
+           flags = HVhek_KEYCANONICAL | (is_utf8 ? HVhek_UTF8 : 0);
+       } else {
+           flags = 0;
+       }
     } else {
        is_utf8 = ((flags & HVhek_UTF8) ? TRUE : FALSE);
     }
@@ -595,7 +599,7 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
        }
     }
 
-    if (is_utf8) {
+    if (is_utf8 & !(flags & HVhek_KEYCANONICAL)) {
        char * const keysave = (char *)key;
        key = (char*)bytes_from_utf8((U8*)key, &klen, &is_utf8);
         if (is_utf8)
@@ -606,6 +610,11 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
            if (flags & HVhek_FREEKEY)
                Safefree(keysave);
             flags |= HVhek_WASUTF8 | HVhek_FREEKEY;
+           /* If the caller calculated a hash, it was on the sequence of
+              octets that are the UTF-8 form. We've now changed the sequence
+              of octets stored to that of the equivalent byte representation,
+              so the hash we need is different.  */
+           hash = 0;
        }
     }
 
@@ -1694,9 +1703,9 @@ S_hfreeentries(pTHX_ HV *hv)
            iter->xhv_eiter = NULL;     /* HvEITER(hv) = NULL */
 
             if((meta = iter->xhv_mro_meta)) {
-               if (meta->mro_linear_dfs) {
-                   SvREFCNT_dec(MUTABLE_SV(meta->mro_linear_dfs));
-                   meta->mro_linear_dfs = NULL;
+               if (meta->mro_linear_all) {
+                   SvREFCNT_dec(MUTABLE_SV(meta->mro_linear_all));
+                   meta->mro_linear_all = NULL;
                    /* This is just acting as a shortcut pointer.  */
                    meta->mro_linear_current = NULL;
                } else if (meta->mro_linear_current) {