summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2019-09-17 14:20:40 +0100
committerDavid Mitchell <davem@iabyn.com>2019-09-19 08:42:46 +0100
commit740449bf2292b54e1824f48789ef1a15877469d5 (patch)
tree779b4f0cc325d4c946583d021a2dc15ce53cd42d /pp_ctl.c
parent20550e1aa3f65750f061802d4df74a3faaf463a9 (diff)
downloadperl-740449bf2292b54e1824f48789ef1a15877469d5.tar.gz
add PL_curstackinfo->si_cxsubix field
This tracks the most recent sub/eval/format context pushed onto the context stack. Then make dopopto_cursub use it. The previous value is saved in the cxt struct, and is restored whenever the context is popped. This adds a tiny overhead for every sub call, but speeds up other operations, such as determining the caller context when returning a value from a sub - this has to be dpne for every sub call where the last expression is context sensitive, so its often a win.
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index 5dee09dddf..ef1ff8dd40 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -37,7 +37,11 @@
#define RUN_PP_CATCHABLY(thispp) \
STMT_START { if (CATCH_GET) return docatch(thispp); } STMT_END
-#define dopopto_cursub() dopoptosub_at(cxstack, cxstack_ix)
+#define dopopto_cursub() \
+ (PL_curstackinfo->si_cxsubix >= 0 \
+ ? PL_curstackinfo->si_cxsubix \
+ : dopoptosub_at(cxstack, cxstack_ix))
+
#define dopoptosub(plop) dopoptosub_at(cxstack, (plop))
PP(pp_wantarray)