summaryrefslogtreecommitdiff
path: root/pad.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-12-14 17:14:23 -0800
committerFather Chrysostomos <sprout@cpan.org>2014-12-14 17:14:23 -0800
commitdd5d1b89ddcc8c8643e05c21ab2e0b2a20a8f4b1 (patch)
tree8f1c623056f290bcbaffcaaba90da505e92643ac /pad.c
parentb9208905f5066956aa5848e6ca7be50db04443be (diff)
downloadperl-dd5d1b89ddcc8c8643e05c21ab2e0b2a20a8f4b1.tar.gz
Don’t set PadlistMAXNAMED for single-char entries
This fixes perl #123430. Single-character entries like "$" and "&" are not actually named entries, but are partially treated as such for the sake of bookkeeping and scope. (E.g., a flipflop target must have the same lifetime as a state variable.) PadlistMAXNAMED is an optimisation that marks the offset of the high- est pad slot with a name. If there any many anonymous pad slots after the last named one, we don’t want to search through them when looking up a symbol. So we mark the maximum named slot and skip half the pad if we are lucky. Commit v5.21.4-51-g14d9114 caused flipflop targets to be allocated as variables named "$", causing compilation of some generated code to slow down. At compile time, the name pad is not extended to the length of the pad until the end of subroutine compilation. So prior to 14d9114 flipflop targets would not make the name pad any longer. Now that flipflop targets expand the name pad, stop setting PadlistMAXNAMED, so that things are no slower than before. This is not really the best fix, IMO, because code that is sensitive to this will slow down dramatically if you tweak it ever so slightly by adding a ‘my $x’ here or there.
Diffstat (limited to 'pad.c')
-rw-r--r--pad.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/pad.c b/pad.c
index 10e957afec..06e5c8cc62 100644
--- a/pad.c
+++ b/pad.c
@@ -561,7 +561,8 @@ S_pad_alloc_name(pTHX_ PADNAME *name, U32 flags, HV *typestash,
}
padnamelist_store(PL_comppad_name, offset, name);
- PadnamelistMAXNAMED(PL_comppad_name) = offset;
+ if (PadnameLEN(name) > 1)
+ PadnamelistMAXNAMED(PL_comppad_name) = offset;
return offset;
}