From 26c4d2af2ef77e1f4278fee221ba1743a74f631d Mon Sep 17 00:00:00 2001 From: Muhammad Zulfaqar Azmi Date: Thu, 21 Sep 2023 15:04:05 +0900 Subject: [PATCH] use partition instead Signed-off-by: Muhammad Zulfaqar Azmi --- .../path_safety_checker/objects_filtering.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/planning/behavior_path_planner/src/utils/path_safety_checker/objects_filtering.cpp b/planning/behavior_path_planner/src/utils/path_safety_checker/objects_filtering.cpp index d86aa88ae050e..e80c23fb5000c 100644 --- a/planning/behavior_path_planner/src/utils/path_safety_checker/objects_filtering.cpp +++ b/planning/behavior_path_planner/src/utils/path_safety_checker/objects_filtering.cpp @@ -105,11 +105,10 @@ void filterObjectsByPosition( return (-backward_distance < dist_ego_to_obj && dist_ego_to_obj < forward_distance); }; - // Create a new container to hold the filtered objects - PredictedObjects filtered = filterObjects(objects, position_filter); - - // Replace the original objects with the filtered list - objects.objects = std::move(filtered.objects); + // Erase objects based on filtered list + objects.objects.erase( + std::partition(objects.objects.begin(), objects.objects.end(), position_filter), + objects.objects.end()); } void filterObjectsByClass( @@ -119,10 +118,10 @@ void filterObjectsByClass( return isTargetObjectType(object, target_object_types); }; - PredictedObjects filtered_objects = filterObjects(objects, object_class_filter); - - // Replace the original objects with the filtered list - objects = std::move(filtered_objects); + // Erase objects based on filtered list + objects.objects.erase( + std::partition(objects.objects.begin(), objects.objects.end(), object_class_filter), + objects.objects.end()); } std::pair, std::vector> separateObjectIndicesByLanelets(