From 68ec467ca846c6215e4599bbb94209cb6cdf4f8d Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Mon, 24 Jun 2013 15:38:51 -0400 Subject: [PATCH] ck_hs: Branch simplification on fast path. Take advantage of probe function invariant (object != NULL) -> (slot != NULL). --- src/ck_hs.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/ck_hs.c b/src/ck_hs.c index 43c15fe..cac2505 100644 --- a/src/ck_hs.c +++ b/src/ck_hs.c @@ -419,12 +419,9 @@ ck_hs_fas(struct ck_hs *hs, if (first != NULL) { ck_pr_store_ptr(first, insert); - - if (*slot != CK_HS_EMPTY) { - ck_pr_inc_uint(&map->generation[h & CK_HS_G_MASK]); - ck_pr_fence_atomic_store(); - ck_pr_store_ptr(slot, CK_HS_TOMBSTONE); - } + ck_pr_inc_uint(&map->generation[h & CK_HS_G_MASK]); + ck_pr_fence_atomic_store(); + ck_pr_store_ptr(slot, CK_HS_TOMBSTONE); } else { ck_pr_store_ptr(slot, insert); } @@ -472,7 +469,7 @@ restart: * period if we can guarantee earlier position of * duplicate key. */ - if (slot != NULL && *slot != CK_HS_EMPTY) { + if (object != NULL) { ck_pr_inc_uint(&map->generation[h & CK_HS_G_MASK]); ck_pr_fence_atomic_store(); ck_pr_store_ptr(slot, CK_HS_TOMBSTONE); @@ -516,7 +513,7 @@ restart: } /* Fail operation if a match was found. */ - if (slot != NULL && *slot != CK_HS_EMPTY) + if (object != NULL) return false; if (n_probes > map->probe_maximum) @@ -576,7 +573,7 @@ ck_hs_remove(struct ck_hs *hs, unsigned long n_probes; slot = ck_hs_map_probe(hs, map, &n_probes, &first, h, key, &object, map->probe_maximum); - if (slot == NULL || object == NULL) + if (object == NULL) return NULL; ck_pr_store_ptr(slot, CK_HS_TOMBSTONE);