Simplify code for SET (since EQUAL returns TRUE as an EMPTY method)

This commit is contained in:
Patrick Pelissier committed 2019-11-02 08:24:42 +01:00
1 parent bc39034f6d
commit 8b71064643
1 file changed
+9 -14
+9 -14
View File
@@ -565,7 +565,7 @@
{ \ { \
assert (it1 != NULL && it2 != NULL); \ assert (it1 != NULL && it2 != NULL); \
return M_C(name, _list_pair_it_equal_p)(it1->list_it, \ return M_C(name, _list_pair_it_equal_p)(it1->list_it, \
it2->list_it); \ it2->list_it); \
} \ } \
\ \
static inline M_C(name, _type_t) * \ static inline M_C(name, _type_t) * \
@@ -599,7 +599,7 @@
assert (dict1 != NULL && dict2 != NULL); \ assert (dict1 != NULL && dict2 != NULL); \
/* NOTE: Key type has mandatory equal operator */ \ /* NOTE: Key type has mandatory equal operator */ \
/* First the easy cases */ \ /* First the easy cases */ \
if (M_LIKELY (dict1->used != dict2-> used)) \ if (M_LIKELY (dict1->used != dict2->used)) \
return false; \ return false; \
if (M_UNLIKELY (dict1->used == 0)) \ if (M_UNLIKELY (dict1->used == 0)) \
return true; \ return true; \
@@ -612,24 +612,19 @@
!M_C(name, _end_p)(it); \ !M_C(name, _end_p)(it); \
M_C(name, _next)(it)) { \ M_C(name, _next)(it)) { \
const M_C(name, _type_t) *item = M_C(name, _cref)(it); \ const M_C(name, _type_t) *item = M_C(name, _cref)(it); \
M_IF(isSet)( \ value_type *ptr = M_C(name, _get)(dict2, M_IF(isSet)(*item, item->key)); \
value_type *ptr = M_C(name, _get)(dict2, *item); \ if (ptr == NULL) \
if (ptr == NULL) \ return false; \
return false; \ if (M_CALL_EQUAL(value_oplist, item->value, *ptr) == false) \
, \ return false; \
value_type *ptr = M_C(name, _get)(dict2, item->key); \ } \
if (ptr == NULL) \
return false; \
if (M_CALL_EQUAL(value_oplist, item->value, *ptr) == false) \
return false; \
) \
} \
return true; \ return true; \
} \ } \
, /* no value equal */ ) \ , /* no value equal */ ) \
\ \
DICTI_FUNC_ADDITIONAL_DEF2(name, key_type, key_oplist, value_type, value_oplist, isSet, dict_t, dict_it_t) DICTI_FUNC_ADDITIONAL_DEF2(name, key_type, key_oplist, value_type, value_oplist, isSet, dict_t, dict_it_t)
/* Define additional functions for dictionnary (Common for all kinds of dictionnary). /* Define additional functions for dictionnary (Common for all kinds of dictionnary).
Do not used any fields of the dictionnary but the public API */ Do not used any fields of the dictionnary but the public API */
#define DICTI_FUNC_ADDITIONAL_DEF2(name, key_type, key_oplist, value_type, value_oplist, isSet, dict_t, dict_it_t) \ #define DICTI_FUNC_ADDITIONAL_DEF2(name, key_type, key_oplist, value_type, value_oplist, isSet, dict_t, dict_it_t) \