Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions nav2_smac_planner/src/a_star.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,11 @@ template<typename NodeT>
typename AStarAlgorithm<NodeT>::NodePtr AStarAlgorithm<NodeT>::addToGraph(
const unsigned int & index)
{
// Emplace will only create a new object if it doesn't already exist.
// If an element exists, it will return the existing object, not create a new one.
auto iter = _graph.find(index);
if (iter != _graph.end()) {
return &(iter->second);
}

return &(_graph.emplace(index, NodeT(index)).first->second);
}

Expand Down