No need to rebalance heap for insertion
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 23 May 2011 21:49:12 +0000 (17:49 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 23 May 2011 21:49:12 +0000 (17:49 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lib/prio_heap/prio_heap.c

index c987d5de18cd10d690aa2c7152c95bc33b621dfa..29af3033812f98ba770ee28b855959b8dca82bfd 100644 (file)
@@ -158,8 +158,11 @@ int heap_insert(struct ptr_heap *heap, void *p)
                        ptrs[pos] = ptrs[parent(pos)];
                        ptrs[parent(pos)] = tmp;
                        pos = parent(pos);
-                       /* rebalance */
-                       heapify(heap, pos);
+                       /*
+                        * No need to rebalance: if we are larger than
+                        * our parent, we are necessarily larger than
+                        * its other child.
+                        */
                } else {
                        break;
                }
This page took 0.026737 seconds and 4 git commands to generate.