summaryrefslogtreecommitdiffstats
path: root/bench/libdimension/kD_splay_tree.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-10-26 00:54:11 +0000
committerTavian Barnes <tavianator@gmail.com>2009-10-26 00:54:11 +0000
commit75f20754030726569ac8cbc243628c18e523f3bb (patch)
tree121ad226fe6fc1d842147b6125be660af638e0df /bench/libdimension/kD_splay_tree.c
parentfa8953f38f0f4b1a2ee3d0704c68750c38e5ec5f (diff)
downloaddimension-75f20754030726569ac8cbc243628c18e523f3bb.tar.xz
Speed up dmnsn_kD_splay_deepest_recursive() a bit.
Diffstat (limited to 'bench/libdimension/kD_splay_tree.c')
-rw-r--r--bench/libdimension/kD_splay_tree.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/bench/libdimension/kD_splay_tree.c b/bench/libdimension/kD_splay_tree.c
index 44a8ef1..bb20a14 100644
--- a/bench/libdimension/kD_splay_tree.c
+++ b/bench/libdimension/kD_splay_tree.c
@@ -71,25 +71,24 @@ dmnsn_kD_splay_deepest_recursive(dmnsn_kD_splay_node *node,
unsigned int depth, unsigned int *deepest)
{
dmnsn_kD_splay_node *left = NULL, *right = NULL;
- unsigned int left_depth = 0, right_depth = 0;
+
if (node->contains) {
- left = dmnsn_kD_splay_deepest_recursive(node->contains,
- depth + 1, &left_depth);
+ left = dmnsn_kD_splay_deepest_recursive(node->contains, depth + 1, deepest);
}
if (node->container) {
right = dmnsn_kD_splay_deepest_recursive(node->container,
- depth + 1, &right_depth);
+ depth + 1, deepest);
}
- if (right && right_depth > left_depth) {
- *deepest = right_depth;
+ if (right) {
return right;
} else if (left) {
- *deepest = left_depth;
return left;
- } else {
+ } else if (depth >= *deepest) {
*deepest = depth;
return node;
+ } else {
+ return NULL;
}
}