summaryrefslogtreecommitdiff
path: root/hv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2009-06-02 11:36:35 +0100
committerNicholas Clark <nick@ccl4.org>2009-06-02 11:36:35 +0100
commit9eb4ebd1619c036262f136e58c5c5417c17be57c (patch)
tree2fa6d453a14331bb8a7c1f1dd575bc62630cbf33 /hv.c
parentee0ea5142b0597d4b2a29b692acbc1c801a05bbf (diff)
downloadperl-9eb4ebd1619c036262f136e58c5c5417c17be57c.tar.gz
In Perl_hv_iternext_flags(), clarify and generalise the empty hash bailout code.
Diffstat (limited to 'hv.c')
-rw-r--r--hv.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/hv.c b/hv.c
index 5f233d6ca1..ebb10fbd34 100644
--- a/hv.c
+++ b/hv.c
@@ -2144,10 +2144,9 @@ Perl_hv_iternext_flags(pTHX_ HV *hv, I32 flags)
}
}
- /* Quick bailout if the hash is empty anyway.
- I don't know if placeholders are included in the KEYS count, so a defensive check
- */
- if (HvKEYS(hv) || (flags & HV_ITERNEXT_WANTPLACEHOLDERS)) {
+ /* Skip the entire loop if the hash is empty. */
+ if ((flags & HV_ITERNEXT_WANTPLACEHOLDERS)
+ ? HvTOTALKEYS(hv) : HvUSEDKEYS(hv)) {
while (!entry) {
/* OK. Come to the end of the current list. Grab the next one. */