Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-08-21 06:29:13 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-08-21 06:29:13 +0400
commit89c7cf1a4938e8ae4008a9a9e1c90bac1a3f93c5 (patch)
treeb5d59042267099bf2723832e4b68b68451040c4c /source/blender/blenlib/intern/sort.c
parent0b0540db3a7c08a1d28653dc8e601e119743e22b (diff)
style cleanup: also use ARRAY_HAS_ITEM macro for mempool check
Diffstat (limited to 'source/blender/blenlib/intern/sort.c')
-rw-r--r--source/blender/blenlib/intern/sort.c24
1 files changed, 15 insertions, 9 deletions
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;
}