X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/0507e8a313738000222ac02e987ad120085a4432..4b6d7cf06534d8a697745dbfe2ab83d56c55d4fc:/op.c diff --git a/op.c b/op.c index e2c7e61..1cac060 100644 --- a/op.c +++ b/op.c @@ -4330,8 +4330,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) : NULL; if (proto) { @@ -4352,8 +4358,6 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block) aname = NULL; /* There may be future conflict here as change 23766 is not yet merged. */ - 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__"),