diff options
author | Father Chrysostomos <sprout@cpan.org> | 2018-01-21 21:55:00 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2018-02-18 16:25:42 -0800 |
commit | 1f1dcfb516e063c29a4b9823ad97b1fc58ffc930 (patch) | |
tree | 7f3616e6e28e78d9e1549eeca675453b6cbfedf7 /regen | |
parent | 6de18f4499a45f0d6876f2aca180b8a9f06e9240 (diff) | |
download | perl-1f1dcfb516e063c29a4b9823ad97b1fc58ffc930.tar.gz |
‘Nonelems’ for pushing sparse array on the stack
To avoid having to create deferred elements every time a sparse array
is pushed on to the stack, store a magic scalar in the array itself,
which av_exists and refto recognise as not existing.
This means there is only a one-time cost for putting such arrays on
the stack.
It also means that deferred elements that live long enough don’t
start pointing to the wrong array entry if the array gets shifted (or
unshifted/spliced) in the mean time. Instead, the scalar is already
in the array, so it cannot lose its place. This fix only applies
when the array as a whole is pushed on to the stack, but it could be
extended in future commits to apply to other places where we currently
use deferred elements.
Diffstat (limited to 'regen')
-rw-r--r-- | regen/mg_vtable.pl | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/regen/mg_vtable.pl b/regen/mg_vtable.pl index 342f5e04c4..f5213b2c21 100644 --- a/regen/mg_vtable.pl +++ b/regen/mg_vtable.pl @@ -92,6 +92,8 @@ my %mg = desc => 'substr() lvalue' }, defelem => { char => 'y', vtable => 'defelem', value_magic => 1, desc => "Shadow \"foreach\" iterator variable /\nsmart parameter vivification" }, + nonelem => { char => 'Y', vtable => 'nonelem', value_magic => 1, + desc => "Array element that does not exist" }, arylen => { char => '#', vtable => 'arylen', value_magic => 1, desc => 'Array length ($#ary)' }, pos => { char => '.', vtable => 'pos', value_magic => 1, @@ -137,6 +139,7 @@ my %sig = 'pos' => {get => 'getpos', set => 'setpos'}, 'uvar' => {get => 'getuvar', set => 'setuvar'}, 'defelem' => {get => 'getdefelem', set => 'setdefelem'}, + 'nonelem' => {set => 'setnonelem'}, 'regexp' => {set => 'setregexp', alias => [qw(bm fm)]}, 'regdata' => {len => 'regdata_cnt'}, 'regdatum' => {get => 'regdatum_get', set => 'regdatum_set'}, |