diff options
author | David Mitchell <davem@iabyn.com> | 2010-07-04 21:44:35 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2010-07-14 23:06:16 +0100 |
commit | e3d2b9e76ba8553f994404cc1438760e83dd8b76 (patch) | |
tree | 195a9d2eefbfa21d2329805860e203d4e871605a /gv.c | |
parent | 044d8c24fa9214cf0fe9c6fc8a44e03f3f5374d7 (diff) | |
download | perl-e3d2b9e76ba8553f994404cc1438760e83dd8b76.tar.gz |
tidy some code in gv_init()
Use an intermediate variable cv to avoid lots of GvCV(gv)'s
Diffstat (limited to 'gv.c')
-rw-r--r-- | gv.c | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -248,10 +248,11 @@ Perl_gv_init(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, int multi) if (multi || doproto) /* doproto means it _was_ mentioned */ GvMULTI_on(gv); if (doproto) { /* Replicate part of newSUB here. */ + CV *cv; ENTER; if (has_constant) { /* newCONSTSUB takes ownership of the reference from us. */ - GvCV(gv) = newCONSTSUB(stash, name, has_constant); + cv = newCONSTSUB(stash, name, has_constant); /* If this reference was a copy of another, then the subroutine must have been "imported", by a Perl space assignment to a GV from a reference to CV. */ @@ -259,16 +260,17 @@ Perl_gv_init(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, int multi) GvIMPORTED_CV_on(gv); } else { (void) start_subparse(0,0); /* Create empty CV in compcv. */ - GvCV(gv) = PL_compcv; + cv = PL_compcv; } + GvCV(gv) = cv; LEAVE; mro_method_changed_in(GvSTASH(gv)); /* sub Foo::bar($) { (shift) } sub ASDF::baz($); *ASDF::baz = \&Foo::bar */ - CvGV(GvCV(gv)) = gv; - CvFILE_set_from_cop(GvCV(gv), PL_curcop); - CvSTASH(GvCV(gv)) = PL_curstash; + CvGV(cv) = gv; + CvFILE_set_from_cop(cv, PL_curcop); + CvSTASH(cv) = PL_curstash; if (proto) { - sv_usepvn_flags(MUTABLE_SV(GvCV(gv)), proto, protolen, + sv_usepvn_flags(MUTABLE_SV(cv), proto, protolen, SV_HAS_TRAILING_NUL); } } |