From 890f5e876a337ffe4b97b2d7363ecbf4ecd38fce Mon Sep 17 00:00:00 2001 From: jcoupey Date: Fri, 4 Aug 2023 09:38:26 +0200 Subject: [PATCH] Reserve vector capacity in initial_routes. --- src/algorithms/heuristics/heuristics.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/algorithms/heuristics/heuristics.cpp b/src/algorithms/heuristics/heuristics.cpp index 4e2ce303e..b5bd52d27 100644 --- a/src/algorithms/heuristics/heuristics.cpp +++ b/src/algorithms/heuristics/heuristics.cpp @@ -886,6 +886,7 @@ T dynamic_vehicle_choice(const Input& input, template T initial_routes(const Input& input) { T routes; + routes.reserve(input.vehicles.size()); for (Index v = 0; v < input.vehicles.size(); ++v) { routes.emplace_back(input, v, input.zero_amount().size()); @@ -912,6 +913,7 @@ template T initial_routes(const Input& input) { Amount current_load = single_jobs_deliveries; std::vector job_ranks; + job_ranks.reserve(vehicle.steps.size()); std::unordered_set expected_delivery_ranks; for (const auto& step : vehicle.steps) { if (step.type != STEP_TYPE::JOB) {