From 1f1dcfb516e063c29a4b9823ad97b1fc58ffc930 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Sun, 21 Jan 2018 21:55:00 -0800 Subject: =?UTF-8?q?=E2=80=98Nonelems=E2=80=99=20for=20pushing=20sparse=20a?= =?UTF-8?q?rray=20on=20the=20stack?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- mg_names.inc | 1 + 1 file changed, 1 insertion(+) (limited to 'mg_names.inc') diff --git a/mg_names.inc b/mg_names.inc index fde6872fa9..7eb9033675 100644 --- a/mg_names.inc +++ b/mg_names.inc @@ -45,6 +45,7 @@ { PERL_MAGIC_vec, "vec(v)" }, { PERL_MAGIC_utf8, "utf8(w)" }, { PERL_MAGIC_substr, "substr(x)" }, + { PERL_MAGIC_nonelem, "nonelem(Y)" }, { PERL_MAGIC_defelem, "defelem(y)" }, { PERL_MAGIC_lvref, "lvref(\\)" }, { PERL_MAGIC_checkcall, "checkcall(])" }, -- cgit v1.2.1