Avoid copying json::Value objects a lot when reallocating vector
This commit is contained in:
parent
c61acaf8be
commit
a4ee2ccb13
@ -16,6 +16,8 @@
|
|||||||
- CHANGED #4845: Updated segregated intersection identification
|
- CHANGED #4845: Updated segregated intersection identification
|
||||||
- Documentation:
|
- Documentation:
|
||||||
- ADDED: Add documentation about OSM node ids in nearest service response [#4436](https://github.com/Project-OSRM/osrm-backend/pull/4436)
|
- ADDED: Add documentation about OSM node ids in nearest service response [#4436](https://github.com/Project-OSRM/osrm-backend/pull/4436)
|
||||||
|
- Performance
|
||||||
|
- FIXED: Speed up response time when lots of legs exist and geojson is used with `steps=true` [#4936](https://github.com/Project-OSRM/osrm-backend/pull/4936)
|
||||||
|
|
||||||
|
|
||||||
# 5.16.0
|
# 5.16.0
|
||||||
|
@ -211,12 +211,16 @@ class RouteAPI : public BaseAPI
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<util::json::Value> step_geometries;
|
std::vector<util::json::Value> step_geometries;
|
||||||
|
const auto total_step_count =
|
||||||
|
std::accumulate(legs.begin(), legs.end(), 0, [](const auto &v, const auto &leg) {
|
||||||
|
return v + leg.steps.size();
|
||||||
|
});
|
||||||
|
step_geometries.reserve(total_step_count);
|
||||||
|
|
||||||
for (const auto idx : util::irange<std::size_t>(0UL, legs.size()))
|
for (const auto idx : util::irange<std::size_t>(0UL, legs.size()))
|
||||||
{
|
{
|
||||||
auto &leg_geometry = leg_geometries[idx];
|
auto &leg_geometry = leg_geometries[idx];
|
||||||
|
|
||||||
step_geometries.reserve(step_geometries.size() + legs[idx].steps.size());
|
|
||||||
|
|
||||||
std::transform(
|
std::transform(
|
||||||
legs[idx].steps.begin(),
|
legs[idx].steps.begin(),
|
||||||
legs[idx].steps.end(),
|
legs[idx].steps.end(),
|
||||||
|
Loading…
Reference in New Issue
Block a user