Avoid copying json::Value objects a lot when reallocating vector
This commit is contained in:
parent
8f633e61bf
commit
7154ed9d59
@ -1,3 +1,8 @@
|
||||
# 5.16.3
|
||||
- Changes from 5.16.2:
|
||||
- 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.2
|
||||
- Changes from 5.16.1:
|
||||
- Bugfixes:
|
||||
|
||||
@ -211,12 +211,16 @@ class RouteAPI : public BaseAPI
|
||||
}
|
||||
|
||||
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()))
|
||||
{
|
||||
auto &leg_geometry = leg_geometries[idx];
|
||||
|
||||
step_geometries.reserve(step_geometries.size() + legs[idx].steps.size());
|
||||
|
||||
std::transform(
|
||||
legs[idx].steps.begin(),
|
||||
legs[idx].steps.end(),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user