summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2010-07-04 21:44:35 +0100
committerRicardo Signes <rjbs@cpan.org>2011-01-14 08:18:18 -0500
commitf56169c089ca3ee19caf13aad88fea6612fd6861 (patch)
tree50e7d33cd07fd115ebbf5f604eaf74c2e2b57949
parent10920ef492d2a4e8b94191d5d9911cecff7f73ce (diff)
downloadperl-f56169c089ca3ee19caf13aad88fea6612fd6861.tar.gz
tidy some code in gv_init()
Use an intermediate variable cv to avoid lots of GvCV(gv)'s
-rw-r--r--gv.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/gv.c b/gv.c
index becd1e909a..73d14caaa1 100644
--- a/gv.c
+++ b/gv.c
@@ -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);
}
}