Move the automatic instantiation of @AnyDBM_File::ISA to Perl_yylex()
authorNicholas Clark <nick@ccl4.org>
Sat, 9 Oct 2010 08:02:15 +0000 (09:02 +0100)
committerNicholas Clark <nick@ccl4.org>
Sat, 9 Oct 2010 08:02:15 +0000 (09:02 +0100)
case KEY_dbmopen in Perl_yylex() has always had special-case code to create
@AnyDBM_File::ISA, using GV_ADDMULTI. S_gv_magicalize_isa() [part of
Perl_gv_fetchpvn_flags()] has special case code to spot "AnyDBM_File::ISA"
being created with GV_ADDMULTI, and populate the variable if it is empty.

Grouping the special case code in one place makes more sense. Removing the
special case code from gv.c means that there is no longer a check clause in the
code path for *every* package's @ISA initialisation.

gv.c
toke.c

diff --git a/gv.c b/gv.c
index 4ad54df..dc8291c 100644 (file)
--- a/gv.c
+++ b/gv.c
@@ -978,21 +978,6 @@ S_gv_magicalize_isa(pTHX_ GV *gv, const char *nambeg, I32 add)
     GvMULTI_on(gv);
     sv_magic(MUTABLE_SV(av), MUTABLE_SV(gv), PERL_MAGIC_isa,
             NULL, 0);
-    /* NOTE: No support for tied ISA */
-    if ((add & GV_ADDMULTI) && strEQ(nambeg,"AnyDBM_File::ISA")
-       && AvFILLp(av) == -1)
-       {
-           av_push(av, newSVpvs("NDBM_File"));
-           gv_stashpvs("NDBM_File", GV_ADD);
-           av_push(av, newSVpvs("DB_File"));
-           gv_stashpvs("DB_File", GV_ADD);
-           av_push(av, newSVpvs("GDBM_File"));
-           gv_stashpvs("GDBM_File", GV_ADD);
-           av_push(av, newSVpvs("SDBM_File"));
-           gv_stashpvs("SDBM_File", GV_ADD);
-           av_push(av, newSVpvs("ODBM_File"));
-           gv_stashpvs("ODBM_File", GV_ADD);
-       }
 }
 
 STATIC void
diff --git a/toke.c b/toke.c
index 9e6a731..55b1970 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -6914,7 +6914,23 @@ Perl_yylex(pTHX)
            UNI(OP_DELETE);
 
        case KEY_dbmopen:
-           gv_fetchpvs("AnyDBM_File::ISA", GV_ADDMULTI, SVt_PVAV);
+           {
+               /* NOTE: No support for tied ISA */
+               AV *isa = get_av("AnyDBM_File::ISA", GV_ADD | GV_ADDMULTI);
+
+               if(AvFILLp(isa) == -1) {
+                   av_push(isa, newSVpvs("NDBM_File"));
+                   gv_stashpvs("NDBM_File", GV_ADD);
+                   av_push(isa, newSVpvs("DB_File"));
+                   gv_stashpvs("DB_File", GV_ADD);
+                   av_push(isa, newSVpvs("GDBM_File"));
+                   gv_stashpvs("GDBM_File", GV_ADD);
+                   av_push(isa, newSVpvs("SDBM_File"));
+                   gv_stashpvs("SDBM_File", GV_ADD);
+                   av_push(isa, newSVpvs("ODBM_File"));
+                   gv_stashpvs("ODBM_File", GV_ADD);
+               }
+           }
            LOP(OP_DBMOPEN,XTERM);
 
        case KEY_dbmclose: