From 5218ec8afc077aee1cb4d6eec303af8eb57782cd Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Wed, 9 May 2012 20:24:39 +0000 Subject: [PATCH] Save just a little time where we can. --- src/mlpack/core/tree/cover_tree_impl.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mlpack/core/tree/cover_tree_impl.hpp b/src/mlpack/core/tree/cover_tree_impl.hpp index f009dd31b7..3bf816c823 100644 --- a/src/mlpack/core/tree/cover_tree_impl.hpp +++ b/src/mlpack/core/tree/cover_tree_impl.hpp @@ -306,7 +306,9 @@ CoverTree::CoverTree( // because all the points in the near set should be used up. farSetSize = childFarSetSize; - ComputeDistances(pointIndex, indices, distances, farSetSize); + // No need to rebuild the distances if we never modified them. + if (nearSet.n_elem != 0) + ComputeDistances(pointIndex, indices, distances, farSetSize); } template