Skip to content

Commit

Permalink
Simplify GET OA_DICT code
Browse files Browse the repository at this point in the history
  • Loading branch information
P-p-H-d committed May 2, 2024
1 parent 150bef4 commit 93429c8
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions m-dict.h
Original file line number Diff line number Diff line change
Expand Up @@ -1487,24 +1487,16 @@ enum m_d1ct_oa_element_e {
M_F(name, _pair_ct) *const data = dict->data; \
const size_t mask = dict->mask; \
size_t p = M_CALL_HASH(key_oplist, key) & mask; \
\
/* Random access, and probably cache miss */ \
if (M_LIKELY (M_CALL_EQUAL(key_oplist, data[p].key, key)) ) \
return &data[p].M_IF(isSet)(key, value); \
else if (M_LIKELY (M_CALL_OOR_EQUAL(key_oplist, data[p].key, M_D1CT_OA_EMPTY)) ) \
return NULL; \
\
/* Unlikely case */ \
size_t s = 1; \
do { \
while (true) { \
/* Random access, and probably cache miss */ \
if (M_LIKELY (M_CALL_EQUAL(key_oplist, data[p].key, key)) ) \
return &data[p].M_IF(isSet)(key, value); \
if (M_LIKELY (M_CALL_OOR_EQUAL(key_oplist, data[p].key, M_D1CT_OA_EMPTY)) ) \
return NULL; \
p = (p + M_D1CT_OA_PROBING(s)) & mask; \
/* data[p].key may be OA_DELETED or OA_EMPTY */ \
if (M_CALL_EQUAL(key_oplist, data[p].key, key)) \
return &data[p].M_IF(isSet)(key, value); \
M_ASSERT (s <= dict->mask); \
} while (!M_CALL_OOR_EQUAL(key_oplist, data[p].key, M_D1CT_OA_EMPTY) ); \
\
return NULL; \
} \
} \
\
M_IF_DEBUG( \
Expand Down

0 comments on commit 93429c8

Please sign in to comment.