summaryrefslogtreecommitdiff
path: root/pp_hot.c
diff options
context:
space:
mode:
authorRichard Leach <richardleach@users.noreply.github.com>2022-11-08 23:40:06 +0000
committerYves Orton <demerphq@gmail.com>2022-11-21 12:40:10 +0100
commitdbf3614df92e720a9536b1cceb915a18ff2b8c08 (patch)
tree4a024e221c8ca84b8bbb14be28ebd890f7ffd610 /pp_hot.c
parentb17e77fbd875a907749400afcdb9da990643edad (diff)
downloadperl-dbf3614df92e720a9536b1cceb915a18ff2b8c08.tar.gz
Extract minimum PV buffer/AV element size to common definitions
In a nutshell, for a long time the minimum PV length (hardcoded in Perl_sv_grow) has been 10 bytes and the minimum AV array size (hardcoded in av_extend_guts) has been 4 elements. These numbers have been used elsewhere for consistency (e.g. Perl_sv_grow_fresh) in the past couple of development cycles. Having a standard definition, rather than hardcoding in multiple places, is more maintainable. This commit therefore introduces into perl.h: PERL_ARRAY_NEW_MIN_KEY PERL_STRLEN_NEW_MIN (Note: Subsequent commit(s) will actually change the values.)
Diffstat (limited to 'pp_hot.c')
-rw-r--r--pp_hot.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/pp_hot.c b/pp_hot.c
index 30a5b35fe2..491cffc305 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -5152,7 +5152,8 @@ Perl_clear_defarray(pTHX_ AV* av, bool abandon)
else {
const SSize_t size = AvFILLp(av) + 1;
/* The ternary gives consistency with av_extend() */
- AV *newav = newAV_alloc_x(size < 4 ? 4 : size);
+ AV *newav = newAV_alloc_x(size < PERL_ARRAY_NEW_MIN_KEY ?
+ PERL_ARRAY_NEW_MIN_KEY : size);
AvREIFY_only(newav);
PAD_SVl(0) = MUTABLE_SV(newav);
SvREFCNT_dec_NN(av);