From 4488853642249af017513c93ed843d3cc07bcfd2 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Sun, 19 Jul 2020 00:59:11 +0200 Subject: [PATCH] Factorization of _sort_union --- m-algo.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/m-algo.h b/m-algo.h index 0e0ea3f5..80e3259d 100644 --- a/m-algo.h +++ b/m-algo.h @@ -458,15 +458,14 @@ type_t const *objDst = M_CALL_IT_CREF(cont_oplist, itDst); \ /* Compare the current element of src and dst */ \ int cmp = cmp_func(name, sort_name, objDst, objSrc); \ - if (cmp == 0) { \ - /* Skip same arguments in both lists */ \ - M_CALL_IT_SET(cont_oplist, itIns, itDst); \ - M_CALL_IT_NEXT(cont_oplist, itSrc); \ - M_CALL_IT_NEXT(cont_oplist, itDst); \ - } else if (cmp < 0) { \ + if (cmp <= 0) { \ /* The element of dst is before. Go to next element of dst */ \ M_CALL_IT_SET(cont_oplist, itIns, itDst); \ M_CALL_IT_NEXT(cont_oplist, itDst); \ + if (cmp == 0) { \ + /* Skip same arguments in both lists */ \ + M_CALL_IT_NEXT(cont_oplist, itSrc); \ + } \ } else { \ /* The element of src is before. */ \ /* insert objSrc before */ \