summaryrefslogtreecommitdiff
path: root/op.h
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 /op.h
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 'op.h')
-rw-r--r--op.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/op.h b/op.h
index e4fadf65b1..e623cd9c47 100644
--- a/op.h
+++ b/op.h
@@ -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)