From: Nicholas Clark Date: Sat, 22 Aug 2009 15:28:32 +0000 (+0100) Subject: In Perl_newATTRSUB(), we know the lengths, so can avoid gv_fetchpv(). X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c1754fcef434d9211b828cbe76693855ba6fb690;p=p5sagit%2Fp5-mst-13.2.git In Perl_newATTRSUB(), we know the lengths, so can avoid gv_fetchpv(). Brought to you by the Campaign for the Elimination of strlen(). --- diff --git a/op.c b/op.c index b4a9fe2..d91e107 100644 --- a/op.c +++ b/op.c @@ -5529,6 +5529,7 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block) { dVAR; const char *aname; + STRLEN aname_len; GV *gv; const char *ps; STRLEN ps_len; @@ -5558,14 +5559,20 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block) PL_curstash ? "__ANON__" : "__ANON__::__ANON__", CopFILE(PL_curcop), (IV)CopLINE(PL_curcop)); aname = SvPVX_const(sv); + aname_len = SvCUR(sv); } else aname = NULL; - gv = name ? gv_fetchsv(cSVOPo->op_sv, gv_fetch_flags, SVt_PVCV) - : gv_fetchpv(aname ? aname - : (PL_curstash ? "__ANON__" : "__ANON__::__ANON__"), - gv_fetch_flags, SVt_PVCV); + if (name) { + gv = gv_fetchsv(cSVOPo->op_sv, gv_fetch_flags, SVt_PVCV); + } else if (aname) { + gv = gv_fetchpvn_flags(aname, aname_len, gv_fetch_flags, SVt_PVCV); + } else if (PL_curstash) { + gv = gv_fetchpvs("__ANON__", gv_fetch_flags, SVt_PVCV); + } else { + gv = gv_fetchpvs("__ANON__::__ANON__", gv_fetch_flags, SVt_PVCV); + } if (!PL_madskills) { if (o)