From 8b71064643d2c994cd4d03db18484d8aa4700620 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Sat, 2 Nov 2019 08:24:42 +0100 Subject: [PATCH] Simplify code for SET (since EQUAL returns TRUE as an EMPTY method) --- m-dict.h | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/m-dict.h b/m-dict.h index 57e65ec4..f832baf8 100644 --- a/m-dict.h +++ b/m-dict.h @@ -565,7 +565,7 @@ { \ assert (it1 != NULL && it2 != NULL); \ 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) * \ @@ -599,7 +599,7 @@ assert (dict1 != NULL && dict2 != NULL); \ /* NOTE: Key type has mandatory equal operator */ \ /* First the easy cases */ \ - if (M_LIKELY (dict1->used != dict2-> used)) \ + if (M_LIKELY (dict1->used != dict2->used)) \ return false; \ if (M_UNLIKELY (dict1->used == 0)) \ return true; \ @@ -612,24 +612,19 @@ !M_C(name, _end_p)(it); \ M_C(name, _next)(it)) { \ const M_C(name, _type_t) *item = M_C(name, _cref)(it); \ - M_IF(isSet)( \ - value_type *ptr = M_C(name, _get)(dict2, *item); \ - if (ptr == NULL) \ - 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; \ - ) \ - } \ + value_type *ptr = M_C(name, _get)(dict2, M_IF(isSet)(*item, item->key)); \ + if (ptr == NULL) \ + return false; \ + if (M_CALL_EQUAL(value_oplist, item->value, *ptr) == false) \ + return false; \ + } \ return true; \ } \ , /* no value equal */ ) \ \ 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). 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) \