Avoid copying ManyToMany table results (#5923)

Regardless of any copy elision on the returned pair value, the
duration and distance results are always copied.

Fix this by passing rvalue references to std::make_pair.
This commit is contained in:
Michael Bell 2021-01-04 16:46:51 +00:00 committed by GitHub
parent dddf83db7b
commit 58ba3fc84f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 8 deletions

View File

@ -4,6 +4,8 @@
- ADDED: Added support for multiple via-way restrictions. [#5907](https://github.com/Project-OSRM/osrm-backend/pull/5907) - ADDED: Added support for multiple via-way restrictions. [#5907](https://github.com/Project-OSRM/osrm-backend/pull/5907)
- ADDED: Add node bindings support for Node 12, 14, and publish binaries [#5918](https://github.com/Project-OSRM/osrm-backend/pull/5918) - ADDED: Add node bindings support for Node 12, 14, and publish binaries [#5918](https://github.com/Project-OSRM/osrm-backend/pull/5918)
- REMOVED: we no longer publish Node 8 binary modules (they are still buildable from source) [#5918](https://github.com/Project-OSRM/osrm-backend/pull/5918) - REMOVED: we no longer publish Node 8 binary modules (they are still buildable from source) [#5918](https://github.com/Project-OSRM/osrm-backend/pull/5918)
- Routing:
- FIXED: Avoid copying ManyToMany table results [#5923](https://github.com/Project-OSRM/osrm-backend/pull/5923)
- Misc: - Misc:
- CHANGED: Unify `.osrm.turn_penalites_index` dump processing same with `.osrm.turn_weight_penalties` and `.osrm.turn_duration_penalties` [#5868](https://github.com/Project-OSRM/osrm-backend/pull/5868) - CHANGED: Unify `.osrm.turn_penalites_index` dump processing same with `.osrm.turn_weight_penalties` and `.osrm.turn_duration_penalties` [#5868](https://github.com/Project-OSRM/osrm-backend/pull/5868)
- Profile: - Profile:

View File

@ -248,7 +248,7 @@ manyToManySearch(SearchEngineData<ch::Algorithm> &engine_working_data,
} }
} }
return std::make_pair(durations_table, distances_table); return std::make_pair(std::move(durations_table), std::move(distances_table));
} }
} // namespace routing_algorithms } // namespace routing_algorithms

View File

@ -219,8 +219,8 @@ oneToManySearch(SearchEngineData<Algorithm> &engine_working_data,
const std::vector<std::size_t> &phantom_indices, const std::vector<std::size_t> &phantom_indices,
const bool calculate_distance) const bool calculate_distance)
{ {
std::vector<EdgeWeight> weights(phantom_indices.size(), INVALID_EDGE_WEIGHT); std::vector<EdgeWeight> weights_table(phantom_indices.size(), INVALID_EDGE_WEIGHT);
std::vector<EdgeDuration> durations(phantom_indices.size(), MAXIMAL_EDGE_DURATION); std::vector<EdgeDuration> durations_table(phantom_indices.size(), MAXIMAL_EDGE_DURATION);
std::vector<EdgeDistance> distances_table(calculate_distance ? phantom_indices.size() : 0, std::vector<EdgeDistance> distances_table(calculate_distance ? phantom_indices.size() : 0,
MAXIMAL_EDGE_DISTANCE); MAXIMAL_EDGE_DISTANCE);
std::vector<NodeID> middle_nodes_table(phantom_indices.size(), SPECIAL_NODEID); std::vector<NodeID> middle_nodes_table(phantom_indices.size(), SPECIAL_NODEID);
@ -298,10 +298,10 @@ oneToManySearch(SearchEngineData<Algorithm> &engine_working_data,
distances_table.empty() ? nulldistance : distances_table[index]; distances_table.empty() ? nulldistance : distances_table[index];
if (std::tie(path_weight, path_duration, path_distance) < if (std::tie(path_weight, path_duration, path_distance) <
std::tie(weights[index], durations[index], current_distance)) std::tie(weights_table[index], durations_table[index], current_distance))
{ {
weights[index] = path_weight; weights_table[index] = path_weight;
durations[index] = path_duration; durations_table[index] = path_duration;
current_distance = path_distance; current_distance = path_distance;
middle_nodes_table[index] = node; middle_nodes_table[index] = node;
} }
@ -392,7 +392,7 @@ oneToManySearch(SearchEngineData<Algorithm> &engine_working_data,
facade, heapNode, query_heap, phantom_nodes, phantom_index, phantom_indices); facade, heapNode, query_heap, phantom_nodes, phantom_index, phantom_indices);
} }
return std::make_pair(durations, distances_table); return std::make_pair(std::move(durations_table), std::move(distances_table));
} }
// //
@ -601,7 +601,7 @@ manyToManySearch(SearchEngineData<Algorithm> &engine_working_data,
} }
} }
return std::make_pair(durations_table, distances_table); return std::make_pair(std::move(durations_table), std::move(distances_table));
} }
} // namespace mld } // namespace mld