Skip to content

Commit c3fa0d6

Browse files
committed
Refactor to avoid calling .at(0) twice
1 parent e2fec6d commit c3fa0d6

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

core/src/solvers/pipeline_planner.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,13 @@ bool PipelinePlanner::plan(const planning_scene::PlanningSceneConstPtr& planning
210210
requests, planning_scene, planning_pipelines_, stopping_criterion_callback_, solution_selection_function_);
211211

212212
// If solutions exist and the first one is successful
213-
if (!responses.empty() && responses.at(0)) {
214-
// Choose the first solution trajectory as response
215-
result = responses.at(0).trajectory;
216-
return bool(result);
213+
if (!responses.empty()) {
214+
auto const solution = responses.at(0);
215+
if (solution) {
216+
// Choose the first solution trajectory as response
217+
result = solution.trajectory;
218+
return bool(result);
219+
}
217220
}
218221
return false;
219222
}

0 commit comments

Comments
 (0)