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 /op.h | |
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 'op.h')
-rw-r--r-- | op.h | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -202,6 +202,8 @@ struct methop { OP* op_first; /* optree for method name */ SV* op_meth_sv; /* static method name */ } op_u; + SV* op_class_sv; /* static class name */ + PADOFFSET op_class_targ; /* pad index for class name if threaded */ }; struct pmop { @@ -441,6 +443,8 @@ struct loop { ? cSVOPx(v)->op_sv : PAD_SVl((v)->op_targ)) # define cSVOPx_svp(v) (cSVOPx(v)->op_sv \ ? &cSVOPx(v)->op_sv : &PAD_SVl((v)->op_targ)) +# define cMETHOPx_class(v) (cMETHOPx(v)->op_class_targ ? \ + PAD_SVl(cMETHOPx(v)->op_class_targ) : cMETHOPx(v)->op_class_sv) #else # define cGVOPx_gv(o) ((GV*)cSVOPx(o)->op_sv) # ifndef PERL_CORE @@ -449,6 +453,7 @@ struct loop { # endif # define cSVOPx_sv(v) (cSVOPx(v)->op_sv) # define cSVOPx_svp(v) (&cSVOPx(v)->op_sv) +# define cMETHOPx_class(v) (cMETHOPx(v)->op_class_sv) #endif # define cMETHOPx_meth(v) cSVOPx_sv(v) |