]> rtime.felk.cvut.cz Git - hubacji1/iamcar2.git/commitdiff
Use local variable for recompute cc method
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Mon, 20 Mar 2023 11:58:36 +0000 (12:58 +0100)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Mon, 20 Mar 2023 11:58:38 +0000 (12:58 +0100)
rrts/src/rrts.cc

index bc87c7f1ada2bab0417d07d7fb028f97d86f3060..5a142174de1babc904991b1b15d0b680cd29e60f 100644 (file)
@@ -149,18 +149,16 @@ RRTNode::operator==(RRTNode const& n)
 void
 RRTS::recompute_cc_for_predecessors_and(RRTNode* g)
 {
-       assert(this->_path.size() == 0);
+       std::vector<RRTNode*> path;
+       path.reserve(this->_path.size());
        while (g != nullptr) {
-               this->_path.push_back(g);
+               path.push_back(g);
                g = g->p();
        }
-       std::reverse(this->_path.begin(), this->_path.end());
-       for (unsigned int i = 1; i < this->_path.size(); i++) {
-               this->_path[i]->c(this->cost_build(
-                       *this->_path[i - 1],
-                       *this->_path[i]));
+       std::reverse(path.begin(), path.end());
+       for (unsigned int i = 1; i < path.size(); i++) {
+               path[i]->c(this->cost_build(*path[i - 1], *path[i]));
        }
-       this->_path.clear();
 }
 
 void