diff options
author | David Mitchell <davem@iabyn.com> | 2019-09-17 14:20:40 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2019-09-19 08:42:46 +0100 |
commit | 740449bf2292b54e1824f48789ef1a15877469d5 (patch) | |
tree | 779b4f0cc325d4c946583d021a2dc15ce53cd42d /pp_ctl.c | |
parent | 20550e1aa3f65750f061802d4df74a3faaf463a9 (diff) | |
download | perl-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.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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) |