op.c: Avoid vivifying CORE::GLOBAL:: globs unnecessarily
authorFather Chrysostomos <sprout@cpan.org>
Mon, 4 Nov 2013 05:51:29 +0000 (21:51 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 4 Nov 2013 13:10:20 +0000 (05:10 -0800)
If we know the upgraded glob is not going to have the IMPORTED_CV
flag, we can avoid upgrading it.

op.c

diff --git a/op.c b/op.c
index 7748e7a..5f48939 100644 (file)
--- a/op.c
+++ b/op.c
@@ -5472,7 +5472,11 @@ S_override(pTHX_ const char * const name, const STRLEN len)
     if (gv && GvCVu(gv) && GvIMPORTED_CV(gv)) return gv;
     gvp = (GV**)hv_fetch(PL_globalstash, name, len, FALSE);
     gv = gvp ? *gvp : NULL;
-    if (gv && !isGV(gv)) gv_init(gv, PL_globalstash, name, len, 0);
+    if (gv && !isGV(gv)) {
+       if (!SvPCS_IMPORTED(gv)) return NULL;
+       gv_init(gv, PL_globalstash, name, len, 0);
+       return gv;
+    }
     return gv && GvCVu(gv) && GvIMPORTED_CV(gv) ? gv : NULL;
 }