diff options
author | David Mitchell <davem@iabyn.com> | 2015-12-27 14:07:02 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2016-02-03 09:19:19 +0000 |
commit | 3caf0269dd4c609b8c2bc22b54598c642ba63ed8 (patch) | |
tree | 15088650105af3273d292e3d54a5ba33b1f91ae3 /scope.c | |
parent | 2ef9a108812a6ae3c346882b7338742e392deb89 (diff) | |
download | perl-3caf0269dd4c609b8c2bc22b54598c642ba63ed8.tar.gz |
offset PL_savestack_max by SS_MAXPUSH
The newer SS_ADD macros expect there to always be SS_MAXPUSH slots
free on the savestack; so they can push multiple items, then only check
once at the end whether stack needs expanding.
This commit makes savestack_grow() set PL_savestack_max to SS_MAXPUSH
short of what has actually been allocated. This makes the tests
to see whether the stack needs growing slightly simpler, i.e.
PL_savestack_ix > PL_savestack_max
rather than
PL_savestack_ix + SS_MAXPUSH > PL_savestack_max
Diffstat (limited to 'scope.c')
-rw-r--r-- | scope.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -140,15 +140,19 @@ Perl_markstack_grow(pTHX) void Perl_savestack_grow(pTHX) { - PL_savestack_max = GROW(PL_savestack_max) + 4; - Renew(PL_savestack, PL_savestack_max, ANY); + PL_savestack_max = GROW(PL_savestack_max); + /* Note that we allocate SS_MAXPUSH slots higher than ss_max + * so that SS_ADD_END(), SSGROW() etc can do a simper check */ + Renew(PL_savestack, PL_savestack_max + SS_MAXPUSH, ANY); } void Perl_savestack_grow_cnt(pTHX_ I32 need) { PL_savestack_max = PL_savestack_ix + need; - Renew(PL_savestack, PL_savestack_max, ANY); + /* Note that we allocate SS_MAXPUSH slots higher than ss_max + * so that SS_ADD_END(), SSGROW() etc can do a simper check */ + Renew(PL_savestack, PL_savestack_max + SS_MAXPUSH, ANY); } #undef GROW |