summaryrefslogtreecommitdiff
path: root/pp_hot.c
diff options
context:
space:
mode:
authorsyber <syber@crazypanda.ru>2014-11-21 20:21:00 +0300
committerFather Chrysostomos <sprout@cpan.org>2014-11-23 22:09:27 -0800
commitb55b14d0f234ed20e6c2a0b6fd8609fa418cddf3 (patch)
tree3302df9d73f287990c0d3518211fbc4d02287384 /pp_hot.c
parent3ea8bc937be5cc09bfcc0beabb3ac6c672b01b67 (diff)
downloadperl-b55b14d0f234ed20e6c2a0b6fd8609fa418cddf3.tar.gz
This commit speeds up class method calls when class name is constant.
I.e. MyClass->method() and MyClass->$dynamic_method() By about 30%. It was done by saving class name (as shared COW string) in METHOP and later checking it in method_common(). If it was set, then it fetches stash via gv_stashsv using precomputed hash value instead of falling into a bunch of conditions and fetching stash without hash value.
Diffstat (limited to 'pp_hot.c')
-rw-r--r--pp_hot.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/pp_hot.c b/pp_hot.c
index 49085257e2..8ec576a0e8 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -3006,15 +3006,21 @@ S_method_common(pTHX_ SV* meth, U32* hashp)
SV* ob;
GV* gv;
HV* stash;
- SV *packsv = NULL;
- SV * const sv = PL_stack_base + TOPMARK == PL_stack_sp
+ SV *packsv = NULL, *const_class, *sv;
+
+ 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
? (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",