This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Refactor some calls to eval_ok() into is(eval $foo ...) and is($@, '') pairs.
[perl5.git] / mro.c
diff --git a/mro.c b/mro.c
index 250ee5c..115da8b 100644 (file)
--- a/mro.c
+++ b/mro.c
@@ -216,7 +216,7 @@ S_mro_get_linear_isa_dfs(pTHX_ HV *stash, U32 level)
     assert(HvAUX(stash));
 
     stashhek
-     = HvAUX(stash)->xhv_name && HvENAME_HEK_NN(stash)
+     = HvAUX(stash)->xhv_name_u.xhvnameu_name && HvENAME_HEK_NN(stash)
         ? HvENAME_HEK_NN(stash)
         : HvNAME_HEK(stash);
 
@@ -744,15 +744,15 @@ Perl_mro_package_moved(pTHX_ HV * const stash, HV * const oldstash,
     name_count = HvAUX(GvSTASH(gv))->xhv_name_count;
     if (!name_count) {
        name_count = 1;
-       namep = &HvAUX(GvSTASH(gv))->xhv_name;
+       namep = &HvAUX(GvSTASH(gv))->xhv_name_u.xhvnameu_name;
     }
     else {
-       namep = (HEK **)HvAUX(GvSTASH(gv))->xhv_name;
+       namep = HvAUX(GvSTASH(gv))->xhv_name_u.xhvnameu_names;
        if (name_count < 0) ++namep, name_count = -name_count - 1;
     }
     if (name_count == 1) {
        if (HEK_LEN(*namep) == 4 && strnEQ(HEK_KEY(*namep), "main", 4)) {
-           namesv = sv_2mortal(newSVpvs(""));
+           namesv = newSVpvs_flags("", SVs_TEMP);
        }
        else {
            namesv = sv_2mortal(newSVhek(*namep));
@@ -830,7 +830,7 @@ S_mro_gather_and_rename(pTHX_ HV * const stashes, HV * const seen_stashes,
     register XPVHV* xhv;
     register HE *entry;
     I32 riter = -1;
-    I32 items;
+    I32 items = 0;
     const bool stash_had_name = stash && HvENAME(stash);
     bool fetched_isarev = FALSE;
     HV *seen = NULL;
@@ -939,7 +939,7 @@ S_mro_gather_and_rename(pTHX_ HV * const stashes, HV * const seen_stashes,
        * mro_isa_changed_in called on it. That happens if it was
        * detached from the symbol table (so it had no HvENAME) before
        * being assigned to the spot named by the ‘name’ variable, because
-       * its cached isa linerisation is now stale (the effective name
+       * its cached isa linearisation is now stale (the effective name
        * having changed), and subclasses will then use that cache when
        * mro_package_moved calls mro_isa_changed_in. (See
        * [perl #77358].)
@@ -984,16 +984,20 @@ S_mro_gather_and_rename(pTHX_ HV * const stashes, HV * const seen_stashes,
     if(!fetched_isarev) {
        /* If oldstash is not null, then we can use its HvENAME to look up
           the isarev hash, since all its subclasses will be listed there.
+          It will always have an HvENAME. It the HvENAME was removed
+          above, then fetch_isarev will be true, and this code will not be
+          reached.
 
           If oldstash is null, then this is an empty spot with no stash in
           it, so subclasses could be listed in isarev hashes belonging to
-          any of the names, so we have to check all of them. */
-       if(oldstash) {
+          any of the names, so we have to check all of them.
+        */
+       assert(!oldstash || HvENAME(oldstash));
+       if (oldstash) {
+           /* Extra variable to avoid a compiler warning */
+           char * const hvename = HvENAME(oldstash);
            fetched_isarev = TRUE;
-           svp
-            = hv_fetch(
-                PL_isarev, HvENAME(oldstash), HvENAMELEN_get(oldstash), 0
-              );
+           svp = hv_fetch(PL_isarev, hvename, HvENAMELEN_get(oldstash), 0);
            if (svp) isarev = MUTABLE_HV(*svp);
        }
        else if(SvTYPE(namesv) == SVt_PVAV) {
@@ -1040,10 +1044,6 @@ S_mro_gather_and_rename(pTHX_ HV * const stashes, HV * const seen_stashes,
       }
     }
 
-    if(
-     (!stash || !HvARRAY(stash)) && (!oldstash || !HvARRAY(oldstash))
-    ) return;
-
     /* This is partly based on code in hv_iternext_flags. We are not call-
        ing that here, as we want to avoid resetting the hash iterator. */