From 89c7cf1a4938e8ae4008a9a9e1c90bac1a3f93c5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 21 Aug 2013 02:29:13 +0000 Subject: style cleanup: also use ARRAY_HAS_ITEM macro for mempool check --- source/blender/blenlib/intern/sort.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'source/blender/blenlib/intern/sort.c') diff --git a/source/blender/blenlib/intern/sort.c b/source/blender/blenlib/intern/sort.c index 1743a0ba6c8..fdfdf5f67ca 100644 --- a/source/blender/blenlib/intern/sort.c +++ b/source/blender/blenlib/intern/sort.c @@ -55,12 +55,12 @@ BLI_INLINE void swapfunc(char *, char *, int, int); #define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \ es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1; -BLI_INLINE void swapfunc(char* a, char* b, int n, int swaptype) +BLI_INLINE void swapfunc(char *a, char *b, int n, int swaptype) { - if(swaptype <= 1) + if (swaptype <= 1) swapcode(long, a, b, n) else - swapcode(char, a, b, n) + swapcode(char, a, b, n) } #define swap(a, b) \ @@ -90,11 +90,14 @@ loop: SWAPINIT(a, es); swap_cnt = 0; if (n < 7) { - for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es) + for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es) { for (pl = pm; - pl > (char *)a && CMP(thunk, pl - es, pl) > 0; - pl -= es) + pl > (char *)a && CMP(thunk, pl - es, pl) > 0; + pl -= es) + { swap(pl, pl - es); + } + } return; } pm = (char *)a + (n / 2) * es; @@ -138,11 +141,14 @@ loop: pc -= es; } if (swap_cnt == 0) { /* Switch to insertion sort */ - for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es) + for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es) { for (pl = pm; - pl > (char *)a && CMP(thunk, pl - es, pl) > 0; - pl -= es) + pl > (char *)a && CMP(thunk, pl - es, pl) > 0; + pl -= es) + { swap(pl, pl - es); + } + } return; } -- cgit v1.2.3