From: Nicholas Clark Date: Tue, 27 Dec 2005 17:33:13 +0000 (+0000) Subject: gv_fetch_flags in newATTRSUB can actually be const. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b48b272aa95a2266df9fecc3e1bbd0e34ff4d9ae;p=p5sagit%2Fp5-mst-13.2.git 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 --- diff --git a/op.c b/op.c index 1e8e43a..fde4f9e 100644 --- a/op.c +++ b/op.c @@ -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__"),