summaryrefslogtreecommitdiff
path: root/lib/hash.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2018-07-06 10:18:11 -0400
committerDonald Sharp <sharpd@cumulusnetworks.com>2018-07-06 10:18:11 -0400
commitdf66eb2eeb7189ab27be49aa8637938cdcf43cb6 (patch)
treee95bd8a1372bfadeee9ca81cec5b7ab79daffe17 /lib/hash.c
parent32ec4bc474972379bc35fdf9f8f9e9dfc0ff93b6 (diff)
Revert "lib: A small optimization for the hash iterate and walk functions"
This reverts commit fc61644e440c875eefa222ab34d726c6281ca806.
Diffstat (limited to 'lib/hash.c')
-rw-r--r--lib/hash.c12
1 files changed, 1 insertions, 11 deletions
diff --git a/lib/hash.c b/lib/hash.c
index 37f6cdcc8f..ee5401b236 100644
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -241,21 +241,15 @@ void hash_iterate(struct hash *hash, void (*func)(struct hash_backet *, void *),
unsigned int i;
struct hash_backet *hb;
struct hash_backet *hbnext;
- uint32_t count = 0;
- for (i = 0; i < hash->size; i++) {
+ for (i = 0; i < hash->size; i++)
for (hb = hash->index[i]; hb; hb = hbnext) {
/* get pointer to next hash backet here, in case (*func)
* decides to delete hb by calling hash_release
*/
hbnext = hb->next;
(*func)(hb, arg);
- count++;
-
}
- if (count == hash->count)
- return;
- }
}
void hash_walk(struct hash *hash, int (*func)(struct hash_backet *, void *),
@@ -265,7 +259,6 @@ void hash_walk(struct hash *hash, int (*func)(struct hash_backet *, void *),
struct hash_backet *hb;
struct hash_backet *hbnext;
int ret = HASHWALK_CONTINUE;
- uint32_t count = 0;
for (i = 0; i < hash->size; i++) {
for (hb = hash->index[i]; hb; hb = hbnext) {
@@ -276,10 +269,7 @@ void hash_walk(struct hash *hash, int (*func)(struct hash_backet *, void *),
ret = (*func)(hb, arg);
if (ret == HASHWALK_ABORT)
return;
- count++;
}
- if (count == hash->count)
- return;
}
}