From be70ffcf01f103235f1cdb06352a48f004603b43 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Thu, 8 Jun 2023 10:36:21 -0400 Subject: [PATCH] remove excessive Unique call to improve efficiency --- gtsam/discrete/DecisionTree-inl.h | 6 +++--- gtsam/discrete/DecisionTree.h | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/gtsam/discrete/DecisionTree-inl.h b/gtsam/discrete/DecisionTree-inl.h index 58de338a8..16a926271 100644 --- a/gtsam/discrete/DecisionTree-inl.h +++ b/gtsam/discrete/DecisionTree-inl.h @@ -627,7 +627,7 @@ namespace gtsam { NodePtr fi = compose(functions.begin(), functions.end(), label); choiceOnHighestLabel->push_back(fi); } - return Choice::Unique(choiceOnHighestLabel); + return choiceOnHighestLabel; } } @@ -691,8 +691,8 @@ namespace gtsam { } /****************************************************************************/ - // Take a range of labels and a corresponding range of values, - // and creates a decision tree. + // Top-level factory method, which takes a range of labels and a corresponding + // range of values, and creates a decision tree. template template typename DecisionTree::NodePtr DecisionTree::create( diff --git a/gtsam/discrete/DecisionTree.h b/gtsam/discrete/DecisionTree.h index a2b05070b..a5d890ab5 100644 --- a/gtsam/discrete/DecisionTree.h +++ b/gtsam/discrete/DecisionTree.h @@ -142,8 +142,10 @@ namespace gtsam { template NodePtr build(It begin, It end, ValueIt beginY, ValueIt endY) const; - /** Internal helper function to create from keys, cardinalities, - * and Y values + /** Internal helper function to create from + * keys, cardinalities, and Y values. + * Calls `build` which builds thetree bottom-up, + * before we prune in a top-down fashion. */ template NodePtr create(It begin, It end, ValueIt beginY, ValueIt endY) const;