diff options
author | syber <syber@crazypanda.ru> | 2014-11-21 20:21:00 +0300 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2014-11-23 22:09:27 -0800 |
commit | b55b14d0f234ed20e6c2a0b6fd8609fa418cddf3 (patch) | |
tree | 3302df9d73f287990c0d3518211fbc4d02287384 /pp_hot.c | |
parent | 3ea8bc937be5cc09bfcc0beabb3ac6c672b01b67 (diff) | |
download | perl-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.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -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", |