From ec7598c64132341ffec3934a78bad178846da36b Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Fri, 3 Sep 2021 08:21:35 +0000 Subject: Use HvTOTALKEYS() in place of HvARRAY() in various boolean tests This is a better choice for an "is it empty?" optimisation, as HvARRAY() can be non-NULL even when there actually are no keys. --- dump.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'dump.c') diff --git a/dump.c b/dump.c index c5c2d9e6ef..07a84b7713 100644 --- a/dump.c +++ b/dump.c @@ -686,7 +686,7 @@ Perl_dump_packsubs_perl(pTHX_ const HV *stash, bool justperl) PERL_ARGS_ASSERT_DUMP_PACKSUBS_PERL; - if (!HvARRAY(stash)) + if (!HvTOTALKEYS(stash)) return; for (i = 0; i <= (I32) HvMAX(stash); i++) { const HE *entry; @@ -2207,12 +2207,12 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo } if (nest < maxnest) { HV * const hv = MUTABLE_HV(sv); - STRLEN i; - HE *he; - if (HvARRAY(hv)) { + if (HvTOTALKEYS(hv)) { + STRLEN i; int count = maxnest - nest; for (i=0; i <= HvMAX(hv); i++) { + HE *he; for (he = HvARRAY(hv)[i]; he; he = HeNEXT(he)) { U32 hash; SV * keysv; -- cgit v1.2.1