summaryrefslogtreecommitdiff
path: root/dump.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2021-09-03 08:21:35 +0000
committerNicholas Clark <nick@ccl4.org>2021-09-03 10:37:55 +0000
commitec7598c64132341ffec3934a78bad178846da36b (patch)
tree8b104c726fdd180a1dd9d5351d6ee58af4c61301 /dump.c
parent8937088f79a80f8cf6f85872e72e9a3b8325e19a (diff)
downloadperl-ec7598c64132341ffec3934a78bad178846da36b.tar.gz
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.
Diffstat (limited to 'dump.c')
-rw-r--r--dump.c8
1 files changed, 4 insertions, 4 deletions
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;