From dbf3614df92e720a9536b1cceb915a18ff2b8c08 Mon Sep 17 00:00:00 2001 From: Richard Leach Date: Tue, 8 Nov 2022 23:40:06 +0000 Subject: 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.) --- av.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'av.c') diff --git a/av.c b/av.c index 5ed203de04..058922de9d 100644 --- a/av.c +++ b/av.c @@ -177,7 +177,8 @@ Perl_av_extend_guts(pTHX_ AV *av, SSize_t key, SSize_t *maxp, SV ***allocp, PL_stack_max = PL_stack_base + newmax; } } else { /* there is no SV* array yet */ - *maxp = key < 3 ? 3 : key; + *maxp = key < PERL_ARRAY_NEW_MIN_KEY ? + PERL_ARRAY_NEW_MIN_KEY : key; { /* see comment above about newmax+1*/ MEM_WRAP_CHECK_s(*maxp, SV*, -- cgit v1.2.1