From d648ffcb179b885089e064ec1d58c60027c80915 Mon Sep 17 00:00:00 2001 From: syber Date: Mon, 24 Nov 2014 18:55:15 +0300 Subject: Remove op_const_class; just use the name on the stack Instead of storing the class name in the op_const_class field of the METHOP in addition to pushing it on to the stack, just use the item on the stack. This also makes $class->method faster if $class is already a shared hash string. --- pp_hot.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'pp_hot.c') diff --git a/pp_hot.c b/pp_hot.c index 8ec576a0e8..cde1d9ff4d 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -3006,27 +3006,27 @@ S_method_common(pTHX_ SV* meth, U32* hashp) SV* ob; GV* gv; HV* stash; - SV *packsv = NULL, *const_class, *sv; + SV *packsv = NULL; - PERL_ARGS_ASSERT_METHOD_COMMON; - - if ((const_class = cMETHOPx_class(PL_op))) { - stash = gv_stashsv(const_class, GV_CACHE_ONLY); - if (stash) goto fetch; - } - - sv = PL_stack_base + TOPMARK == PL_stack_sp + SV* const sv = PL_stack_base + TOPMARK == PL_stack_sp ? (Perl_croak(aTHX_ "Can't call method \"%"SVf"\" without a " "package or object reference", SVfARG(meth)), (SV *)NULL) : *(PL_stack_base + TOPMARK + 1); + PERL_ARGS_ASSERT_METHOD_COMMON; + if (UNLIKELY(!sv)) undefined: Perl_croak(aTHX_ "Can't call method \"%"SVf"\" on an undefined value", SVfARG(meth)); - SvGETMAGIC(sv); + if (UNLIKELY(SvGMAGICAL(sv))) mg_get(sv); + else if (SvIsCOW_shared_hash(sv)) { /* MyClass->meth() */ + stash = gv_stashsv(sv, GV_CACHE_ONLY); + if (stash) goto fetch; + } + if (SvROK(sv)) ob = MUTABLE_SV(SvRV(sv)); else if (!SvOK(sv)) goto undefined; -- cgit v1.2.1