This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Only call mro_package_moved on new substashes
authorFather Chrysostomos <sprout@cpan.org>
Tue, 23 Nov 2010 00:55:19 +0000 (16:55 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 23 Nov 2010 00:55:19 +0000 (16:55 -0800)
Commit 298d65111 added this mro_package_moved call.

It does not need to happen if the substash already exists, as it will
already have had effective names assigned to it.

It also may not be a good idea to set it in such cases, as it may make
a recursive call to mro_get_linear_isa. I know this is utter paranoia,
but someone may write a mro plugin that is not re├źntrant. (The speed
gain is worth it, though.)

gv.c

diff --git a/gv.c b/gv.c
index 9a72996..b2cb5a4 100644 (file)
--- a/gv.c
+++ b/gv.c
@@ -1072,16 +1072,18 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags,
                    return NULL;
 
                if (!(stash = GvHV(gv)))
-                   stash = GvHV(gv) = newHV();
-
-               if (!HvNAME_get(stash))
                {
-                   hv_name_set(stash, nambeg, name_cursor - nambeg, 0);
-                   /* If the containing stash has multiple effective
-                      names, see that this one gets them, too. */
-                   if (HvAUX(GvSTASH(gv))->xhv_name_count)
-                       mro_package_moved(stash, NULL, gv, 1);
+                   stash = GvHV(gv) = newHV();
+                   if (!HvNAME_get(stash)) {
+                       hv_name_set(stash, nambeg, name_cursor-nambeg, 0);
+                       /* If the containing stash has multiple effective
+                          names, see that this one gets them, too. */
+                       if (HvAUX(GvSTASH(gv))->xhv_name_count)
+                           mro_package_moved(stash, NULL, gv, 1);
+                   }
                }
+               else if (!HvNAME_get(stash))
+                   hv_name_set(stash, nambeg, name_cursor - nambeg, 0);
            }
 
            if (*name_cursor == ':')