From a1c36810027f353ead8b634fc825e3771f592527 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Sat, 22 Sep 2018 11:37:23 +0200 Subject: [PATCH] Optimization of _init_set for list. --- m-list.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/m-list.h b/m-list.h index b0d08a0a..ff9e7227 100644 --- a/m-list.h +++ b/m-list.h @@ -441,14 +441,11 @@ } \ \ static inline void \ - M_C(name, _set)(list_t list, const list_t org) \ + M_C(name, _init_set)(list_t list, const list_t org) \ { \ - LISTI_CONTRACT(list); \ LISTI_CONTRACT(org); \ struct M_C(name, _s) *next, *it_org; \ struct M_C(name, _s) **update_list; \ - if (list == org) return; \ - M_C(name, _clean)(list); \ update_list = list; \ it_org = *org; \ while (it_org != NULL) { \ @@ -464,13 +461,15 @@ it_org = it_org->next; \ } \ *update_list = NULL; \ + LISTI_CONTRACT(list); \ } \ \ static inline void \ - M_C(name, _init_set)(list_t list, const list_t org) \ + M_C(name, _set)(list_t list, const list_t org) \ { \ - M_C(name, _init)(list); \ - M_C(name, _set)(list, org); \ + if (M_UNLIKELY (list == org)) return; \ + M_C(name, _clear)(list); \ + M_C(name, _init_set)(list, org); \ } \ \ static inline void \