code clean up
[oweals/gnunet.git] / src / util / container_heap.c
index dbb391ac4e5e949feaf802af40993be7c9195f47..78881d8081d898aa8b67c357cc17081b7dfa0cd6 100644 (file)
@@ -267,6 +267,7 @@ GNUNET_CONTAINER_heap_walk_get_next (struct GNUNET_CONTAINER_Heap *heap)
  * Insert the given node 'node' into the subtree starting
  * at 'pos' (while keeping the tree somewhat balanced).
  *
+ * @param heap heap to modify
  * @param pos existing tree
  * @param node node to insert (which may be a subtree itself)
  */
@@ -278,7 +279,9 @@ insert_node (struct GNUNET_CONTAINER_Heap *heap,
   struct GNUNET_CONTAINER_HeapNode *parent;
 
   GNUNET_assert (node->parent == NULL);
-  while ( (pos->cost < node->cost) ^ (heap->order == GNUNET_CONTAINER_HEAP_ORDER_MAX) )
+  while ( (heap->order == GNUNET_CONTAINER_HEAP_ORDER_MAX) 
+         ? (pos->cost >= node->cost) 
+         : (pos->cost <= node->cost) )
     {
       /* node is descendent of pos */
       pos->tree_size += (1 + node->tree_size);