From: Nicholas Clark Date: Sat, 13 Mar 2010 11:23:46 +0000 (+0000) Subject: Perl_hv_fill(), count empty chains down, rather than used chains up. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fcd24582e9751804a977b6d4ef227de5a3b0343b;p=p5sagit%2Fp5-mst-13.2.git 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. --- diff --git a/hv.c b/hv.c index 244feb6..1ff73b0 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; }