]> git.itanic.dy.fi Git - sdl-planets/commitdiff
quadtree: Move quadtree_recalculate_parent_stats() out from the header
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Fri, 8 Jul 2011 10:03:21 +0000 (13:03 +0300)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Sat, 9 Jul 2011 07:29:17 +0000 (10:29 +0300)
This function is not called anywhere outside of the quadtree.c, so
there is no really point in keeping it in the header. Furthermore,
this is one quite big function to keep inlined. Make it an ordinary
static function instead and let the compiler decide whether it should
be inlined or not.

Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
quadtree.c
quadtree.h

index 60ecd6db737a7640d17811f74799d97ed6f1a7af..1417c54ca132583eb20e392809147a9089e7cf15 100644 (file)
@@ -189,6 +189,35 @@ static struct quadtree *_quadtree_add(struct quadtree *parent,
        return new;
 }
 
        return new;
 }
 
+/*
+ * Recursively walk through the tree and propagate changes made to the
+ * given node up until the highest parent.
+ */
+static void quadtree_recalculate_parent_stats(struct quadtree *node,
+                                                    struct quadtree_ops *ops)
+{
+       int i;
+
+       while (node) {
+               node->depth = 0;
+               node->children = 0;
+
+               for (i = 0; i < 4; i++) {
+                       if (!node->child[i])
+                               continue;
+
+                       node->depth = MAX(node->depth,
+                                         node->child[i]->depth + 1);
+                       node->children += node->child[i]->children + 1;
+               }
+
+               if (ops->recalculate_stats)
+                       ops->recalculate_stats(node);
+
+               node = node->parent;
+       }
+}
+
 /**
  * quadtree_add - add a node to a quadtree
  * @parent: parent node
 /**
  * quadtree_add - add a node to a quadtree
  * @parent: parent node
index 45478fa73a83cb711ddc7fbed69c68ac5b054803..f69f34d0784198d169d6de735cb266a09d4eda03 100644 (file)
@@ -70,33 +70,4 @@ static inline struct quadtree *quadtree_find_parent(const struct quadtree *node)
        return t;
 }
 
        return t;
 }
 
-/*
- * Recursively walk through the tree and propagate changes made to the
- * given node up until the highest parent.
- */
-static inline void quadtree_recalculate_parent_stats(struct quadtree *node,
-                                                    struct quadtree_ops *ops)
-{
-       int i;
-
-       while (node) {
-               node->depth = 0;
-               node->children = 0;
-
-               for (i = 0; i < 4; i++) {
-                       if (!node->child[i])
-                               continue;
-
-                       node->depth = MAX(node->depth,
-                                         node->child[i]->depth + 1);
-                       node->children += node->child[i]->children + 1;
-               }
-
-               if (ops->recalculate_stats)
-                       ops->recalculate_stats(node);
-
-               node = node->parent;
-       }
-}
-
 #endif
 #endif