Skip to content

Commit

Permalink
Code optimization.
Browse files Browse the repository at this point in the history
  • Loading branch information
twose committed Apr 11, 2019
1 parent 44ad792 commit 14634bb
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/core/hashmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,7 @@ static sw_inline int swHashMap_node_add(swHashMap_node *root, swHashMap_node *ad

static sw_inline swHashMap_node* swHashMap_node_each(swHashMap* hmap)
{
swHashMap_node *iterator = hmap->iterator;
if (hmap->root->hh.tbl->num_items == 0)
{
return NULL;
}
if (iterator == NULL)
{
iterator = hmap->root;
}
return hmap->iterator = iterator->hh.next;
return hmap->iterator ? hmap->iterator->hh.next : NULL;
}

swHashMap* swHashMap_new(uint32_t bucket_num, swHashMap_dtor dtor)
Expand Down Expand Up @@ -321,7 +312,7 @@ int swHashMap_move_int(swHashMap *hmap, uint64_t old_key, uint64_t new_key)

void swHashMap_rewind(swHashMap* hmap)
{
hmap->iterator = NULL;
hmap->iterator = hmap->root;
}

void* swHashMap_each(swHashMap* hmap, char **key)
Expand Down

0 comments on commit 14634bb

Please sign in to comment.