ck_hs: Merge post-insertion logic into one function.

ck_pring
Samy Al Bahra 11 years ago
parent 92645aeb47
commit d167c417a4

@ -369,6 +369,17 @@ restart:
return true; return true;
} }
static void
ck_hs_map_postinsert(struct ck_hs *hs, struct ck_hs_map *map)
{
map->n_entries++;
if ((map->n_entries << 1) > map->capacity)
ck_hs_grow(hs, map->capacity << 1);
return;
}
bool bool
ck_hs_rebuild(struct ck_hs *hs) ck_hs_rebuild(struct ck_hs *hs)
{ {
@ -706,11 +717,8 @@ restart:
ck_pr_store_ptr(slot, insert); ck_pr_store_ptr(slot, insert);
} }
if (object == NULL) { if (object == NULL)
map->n_entries++; ck_hs_map_postinsert(hs, map);
if ((map->n_entries << 1) > map->capacity)
ck_hs_grow(hs, map->capacity << 1);
}
return true; return true;
} }
@ -765,11 +773,8 @@ restart:
ck_pr_store_ptr(slot, insert); ck_pr_store_ptr(slot, insert);
} }
if (object == NULL) { if (object == NULL)
map->n_entries++; ck_hs_map_postinsert(hs, map);
if ((map->n_entries << 1) > map->capacity)
ck_hs_grow(hs, map->capacity << 1);
}
*previous = object; *previous = object;
return true; return true;
@ -813,10 +818,7 @@ restart:
ck_pr_store_ptr(slot, insert); ck_pr_store_ptr(slot, insert);
} }
map->n_entries++; ck_hs_map_postinsert(hs, map);
if ((map->n_entries << 1) > map->capacity)
ck_hs_grow(hs, map->capacity << 1);
return true; return true;
} }

Loading…
Cancel
Save