[mlpack] 03/58: Simplify some loops.

Barak A. Pearlmutter barak+git at cs.nuim.ie
Tue Sep 9 13:19:38 UTC 2014


This is an automated email from the git hooks/post-receive script.

bap pushed a commit to branch svn-trunk
in repository mlpack.

commit 7b3dd2c4a849afb143b6f976a215da395d6c65df
Author: rcurtin <rcurtin at 9d5b8971-822b-0410-80eb-d18c1038ef23>
Date:   Sun Aug 17 05:00:05 2014 +0000

    Simplify some loops.
    
    
    git-svn-id: http://svn.cc.gatech.edu/fastlab/mlpack/trunk@17048 9d5b8971-822b-0410-80eb-d18c1038ef23
---
 .../core/tree/rectangle_tree/r_tree_split_impl.hpp | 24 ++++++----------------
 1 file changed, 6 insertions(+), 18 deletions(-)

diff --git a/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp b/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp
index 1469fbe..7a73eff 100644
--- a/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp
@@ -60,15 +60,9 @@ void RTreeSplit<DescentType, StatisticType, MatType>::SplitLeafNode(
 
   // Remove this node and insert treeOne and treeTwo.
   TreeType* par = tree->Parent();
-  int index = 0;
-  for (int i = 0; i < par->NumChildren(); i++)
-  {
-    if (par->Children()[i] == tree)
-    {
-      index = i;
-      break;
-    }
-  }
+  size_t index = 0;
+  while (par->Children()[index] != tree) { ++index; }
+
   par->Children()[index] = treeOne;
   par->Children()[par->NumChildren()++] = treeTwo;
 
@@ -130,15 +124,9 @@ bool RTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
 
   // Remove this node and insert treeOne and treeTwo.
   TreeType* par = tree->Parent();
-  int index = -1;
-  for (int i = 0; i < par->NumChildren(); i++)
-  {
-    if (par->Children()[i] == tree)
-    {
-      index = i;
-      break;
-    }
-  }
+  size_t index = 0;
+  while (par->Children()[index] != tree) { ++index; }
+
   assert(index != -1);
   par->Children()[index] = treeOne;
   par->Children()[par->NumChildren()++] = treeTwo;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mlpack.git



More information about the debian-science-commits mailing list