diff options
author | Nicholas Clark <nick@ccl4.org> | 2010-03-13 11:23:46 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2010-05-21 18:56:25 +0100 |
commit | fcd24582e9751804a977b6d4ef227de5a3b0343b (patch) | |
tree | 342534eabb14b55cdcef48baa9e42fb8b443042a /hv.c | |
parent | 359164a0b0ca9d7142b89ef0b09c1d01437e4471 (diff) | |
download | perl-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.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -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; } |