Skip to content

Commit

Permalink
Reserve vector capacity in initial_routes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoupey committed Aug 4, 2023
1 parent dea3333 commit 890f5e8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/algorithms/heuristics/heuristics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,7 @@ T dynamic_vehicle_choice(const Input& input,

template <class T> 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());

Expand All @@ -912,6 +913,7 @@ template <class T> T initial_routes(const Input& input) {
Amount current_load = single_jobs_deliveries;

std::vector<Index> job_ranks;
job_ranks.reserve(vehicle.steps.size());
std::unordered_set<Index> expected_delivery_ranks;
for (const auto& step : vehicle.steps) {
if (step.type != STEP_TYPE::JOB) {
Expand Down

0 comments on commit 890f5e8

Please sign in to comment.