summaryrefslogtreecommitdiff
path: root/hv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-03-13 11:23:46 +0000
committerNicholas Clark <nick@ccl4.org>2010-05-21 18:56:25 +0100
commitfcd24582e9751804a977b6d4ef227de5a3b0343b (patch)
tree342534eabb14b55cdcef48baa9e42fb8b443042a /hv.c
parent359164a0b0ca9d7142b89ef0b09c1d01437e4471 (diff)
downloadperl-fcd24582e9751804a977b6d4ef227de5a3b0343b.tar.gz
Perl_hv_fill(), count empty chains down, rather than used chains up.
The assumption is that most chains of a hash are in use. Suggestion and initial patch by Ruslan Zakirov.
Diffstat (limited to 'hv.c')
-rw-r--r--hv.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/hv.c b/hv.c
index 244feb63ca..1ff73b0c49 100644
--- a/hv.c
+++ b/hv.c
@@ -1880,12 +1880,13 @@ Perl_hv_fill(pTHX_ HV const *const hv)
PERL_ARGS_ASSERT_HV_FILL;
if (ents) {
- HE *const *const end = ents + HvMAX(hv);
+ HE *const *const last = ents + HvMAX(hv);
+ count = last + 1 - ents;
do {
- if (*ents)
- ++count;
- } while (++ents <= end);
+ if (!*ents)
+ --count;
+ } while (++ents <= last);
}
return count;
}