From 93c0e1dab3ac4b3d77323a2a535af898d1b05fee Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Sat, 29 Jun 2024 19:59:08 +0200 Subject: [PATCH] Micro performance optimisation in map matching (#6976) --- CHANGELOG.md | 1 + src/engine/routing_algorithms/map_matching.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1495a57d26b..22bebae0d05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ - NodeJS: - CHANGED: Use node-api instead of NAN. [#6452](https://github.com/Project-OSRM/osrm-backend/pull/6452) - Misc: + - CHANGED: Micro performance optimisation in map matching. [#6976](https://github.com/Project-OSRM/osrm-backend/pull/6976) - CHANGED: Re-use priority queue in StaticRTree. [#6952](https://github.com/Project-OSRM/osrm-backend/pull/6952) - CHANGED: Optimise encodePolyline function. [#6940](https://github.com/Project-OSRM/osrm-backend/pull/6940) - CHANGED: Avoid reallocations in base64 encoding. [#6951](https://github.com/Project-OSRM/osrm-backend/pull/6951) diff --git a/src/engine/routing_algorithms/map_matching.cpp b/src/engine/routing_algorithms/map_matching.cpp index 9f8a1d2a556..41f1f340585 100644 --- a/src/engine/routing_algorithms/map_matching.cpp +++ b/src/engine/routing_algorithms/map_matching.cpp @@ -401,6 +401,7 @@ SubMatchingList mapMatching(SearchEngineData &engine_working_data, auto trace_distance = 0.0; matching.nodes.reserve(reconstructed_indices.size()); matching.indices.reserve(reconstructed_indices.size()); + matching.alternatives_count.reserve(reconstructed_indices.size()); for (const auto &idx : reconstructed_indices) { const auto timestamp_index = idx.first; @@ -428,7 +429,7 @@ SubMatchingList mapMatching(SearchEngineData &engine_working_data, matching.confidence = confidence(trace_distance, matching_distance); - sub_matchings.push_back(matching); + sub_matchings.emplace_back(std::move(matching)); sub_matching_begin = sub_matching_end; }