Skip to content

Commit 876f3c8

Browse files
committed
Avoid double search of pipeline_id_planner_id_map_
1 parent bbe6b4c commit 876f3c8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

core/src/solvers/pipeline_planner.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,14 @@ PipelinePlanner::PipelinePlanner(
9393

9494
bool PipelinePlanner::setPlannerId(const std::string& pipeline_name, const std::string& planner_id) {
9595
// Only set ID if pipeline exists. It is not possible to create new pipelines with this command.
96-
if (pipeline_id_planner_id_map_.count(pipeline_name) == 0) {
96+
auto it = pipeline_id_planner_id_map_.find(pipeline_name);
97+
if (it == pipeline_id_planner_id_map_.end()) {
9798
RCLCPP_ERROR(node_->get_logger(),
9899
"PipelinePlanner does not have a pipeline called '%s'. Cannot set pipeline ID '%s'",
99100
pipeline_name.c_str(), planner_id.c_str());
100101
return false;
101102
}
102-
pipeline_id_planner_id_map_[pipeline_name] = planner_id;
103+
it->second = planner_id;
103104
return true;
104105
}
105106

0 commit comments

Comments
 (0)