This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
gv.c: Don’t ENTER/LEAVE unnecessarily
authorFather Chrysostomos <sprout@cpan.org>
Sun, 10 Jun 2012 18:17:40 +0000 (11:17 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 15 Jun 2012 19:28:14 +0000 (12:28 -0700)
Commit 756cb47730 added an if/else block in between ENTER/LEAVE, mov-
ing the existing code into the else block.  But the if code (consist-
ing of newCONSTSUB) never needed to be surrounded by ENTER/LEAVE.

gv.c

diff --git a/gv.c b/gv.c
index 020e2a2..469d46a 100644 (file)
--- a/gv.c
+++ b/gv.c
@@ -370,7 +370,6 @@ Perl_gv_init_pvn(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, U32 flag
        GvMULTI_on(gv);                 /* _was_ mentioned */
     if (doproto) {                     /* Replicate part of newSUB here. */
        CV *cv;
-       ENTER;
        if (has_constant) {
            /* newCONSTSUB takes ownership of the reference from us.  */
            cv = newCONSTSUB_flags(stash, name, len, flags, has_constant);
@@ -384,11 +383,12 @@ Perl_gv_init_pvn(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, U32 flag
            if (exported_constant)
                GvIMPORTED_CV_on(gv);
        } else {
+           ENTER;
            (void) start_subparse(0,0); /* Create empty CV in compcv. */
            cv = PL_compcv;
            GvCV_set(gv,cv);
+           LEAVE;
        }
-       LEAVE;
 
         mro_method_changed_in(GvSTASH(gv)); /* sub Foo::bar($) { (shift) } sub ASDF::baz($); *ASDF::baz = \&Foo::bar */
        CvGV_set(cv, gv);