diff options
author | Nicholas Clark <nick@ccl4.org> | 2005-12-27 17:33:13 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2005-12-27 17:33:13 +0000 |
commit | b48b272aa95a2266df9fecc3e1bbd0e34ff4d9ae (patch) | |
tree | 4dd28d102f23f862c5f597666dddd4e3fbe1b6f4 /op.c | |
parent | e1234d8e95fb69a46c5f20bacb0c0cd2f1c325f7 (diff) | |
download | perl-b48b272aa95a2266df9fecc3e1bbd0e34ff4d9ae.tar.gz |
gv_fetch_flags in newATTRSUB can actually be const.
Comment the logic behind the terms in the ternary that chooses the
flags value.
p4raw-id: //depot/perl@26503
Diffstat (limited to 'op.c')
-rw-r--r-- | op.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -4440,8 +4440,14 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block) STRLEN ps_len; register CV *cv = NULL; SV *const_sv; - I32 gv_fetch_flags; - + /* If the subroutine has no body, no attributes, and no builtin attributes + then it's just a sub declaration, and we may be able to get away with + storing with a placeholder scalar in the symbol table, rather than a + full GV and CV. If anything is present then it will take a full CV to + store it. */ + const I32 gv_fetch_flags + = (block || attrs || (CvFLAGS(PL_compcv) & CVf_BUILTIN_ATTRS)) + ? GV_ADDMULTI : GV_ADDMULTI | GV_NOINIT; const char * const name = o ? SvPVx_nolen_const(cSVOPo->op_sv) : Nullch; if (proto) { @@ -4461,8 +4467,6 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block) else aname = Nullch; - gv_fetch_flags = (block || attrs || (CvFLAGS(PL_compcv) & CVf_BUILTIN_ATTRS)) - ? GV_ADDMULTI : GV_ADDMULTI | GV_NOINIT; gv = name ? gv_fetchsv(cSVOPo->op_sv, gv_fetch_flags, SVt_PVCV) : gv_fetchpv(aname ? aname : (PL_curstash ? "__ANON__" : "__ANON__::__ANON__"), |