Revert "lib: A small optimization for the hash iterate and walk functions"

This reverts commit fc61644e440c875eefa222ab34d726c6281ca806.
This commit is contained in:
Donald Sharp 2018-07-06 10:18:11 -04:00
parent 32ec4bc474
commit df66eb2eeb
2 changed files with 2 additions and 11 deletions

View File

@ -241,21 +241,15 @@ void hash_iterate(struct hash *hash, void (*func)(struct hash_backet *, void *),
unsigned int i; unsigned int i;
struct hash_backet *hb; struct hash_backet *hb;
struct hash_backet *hbnext; 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) { for (hb = hash->index[i]; hb; hb = hbnext) {
/* get pointer to next hash backet here, in case (*func) /* get pointer to next hash backet here, in case (*func)
* decides to delete hb by calling hash_release * decides to delete hb by calling hash_release
*/ */
hbnext = hb->next; hbnext = hb->next;
(*func)(hb, arg); (*func)(hb, arg);
count++;
} }
if (count == hash->count)
return;
}
} }
void hash_walk(struct hash *hash, int (*func)(struct hash_backet *, void *), 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 *hb;
struct hash_backet *hbnext; struct hash_backet *hbnext;
int ret = HASHWALK_CONTINUE; int ret = HASHWALK_CONTINUE;
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) { 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); ret = (*func)(hb, arg);
if (ret == HASHWALK_ABORT) if (ret == HASHWALK_ABORT)
return; return;
count++;
} }
if (count == hash->count)
return;
} }
} }

View File

@ -2144,6 +2144,7 @@ DEFUN (vtysh_show_poll,
"Thread Poll Information\n") "Thread Poll Information\n")
{ {
unsigned int i; unsigned int i;
int idx = 0;
int ret = CMD_SUCCESS; int ret = CMD_SUCCESS;
char line[100]; char line[100];