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>2012-10-22 17:00:02 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-10-22 17:00:02 +0400
commit436bbdfd247f66a856b17e4e73db8f8fb3fe6d6d (patch)
treec72eb1ce03d701a7a99ab0b039f89b20af28374c /source/blender/blenlib/intern/BLI_heap.c
parent4e11fe6c5aec1d609e3ecc2218138b838d253ebf (diff)
style cleanup: use more const's in BLI_heap & dpx/cineon style cleanup
Diffstat (limited to 'source/blender/blenlib/intern/BLI_heap.c')
-rw-r--r--source/blender/blenlib/intern/BLI_heap.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/source/blender/blenlib/intern/BLI_heap.c b/source/blender/blenlib/intern/BLI_heap.c
index 42dca360f4c..dcc028630e2 100644
--- a/source/blender/blenlib/intern/BLI_heap.c
+++ b/source/blender/blenlib/intern/BLI_heap.c
@@ -84,10 +84,13 @@ BLI_INLINE void heap_swap(Heap *heap, const unsigned int i, const unsigned int j
static void heap_down(Heap *heap, unsigned int i)
{
+ /* size won't change in the loop */
+ const unsigned int size = heap->size;
+
while (1) {
- unsigned int size = heap->size,smallest ;
- unsigned int l = HEAP_LEFT(i);
- unsigned int r = HEAP_RIGHT(i);
+ const unsigned int l = HEAP_LEFT(i);
+ const unsigned int r = HEAP_RIGHT(i);
+ unsigned int smallest;
smallest = ((l < size) && HEAP_COMPARE(heap->tree[l], heap->tree[i])) ? l : i;
@@ -105,7 +108,7 @@ static void heap_down(Heap *heap, unsigned int i)
static void heap_up(Heap *heap, unsigned int i)
{
while (i > 0) {
- unsigned int p = HEAP_PARENT(i);
+ const unsigned int p = HEAP_PARENT(i);
if (HEAP_COMPARE(heap->tree[p], heap->tree[i]))
break;
@@ -139,9 +142,11 @@ void BLI_heap_free(Heap *heap, HeapFreeFP ptrfreefp)
{
unsigned int i;
- if (ptrfreefp)
- for (i = 0; i < heap->size; i++)
+ if (ptrfreefp) {
+ for (i = 0; i < heap->size; i++) {
ptrfreefp(heap->tree[i]->ptr);
+ }
+ }
MEM_freeN(heap->tree);
BLI_memarena_free(heap->arena);