2.x branch optimization
@flippmoke is already working on this.
Since Jan 17, 2018.
- Dominant language
- C++
- Stars
- 52
- Forks
- 33
- PR merge metrics
- No merged PRs in 30d
Description
I noticed that `layer_map decode_tile(std::string const& buffer)` at https://github.com/mapbox/vector-tile/blob/95c240bd8c8373bc0c06966a62565c5d73fdef73/include/mapbox/vector_tile.hpp#L62-L84 does not leverage pre-allocation optimizations. We should likely do:
```diff
diff --git a/include/mapbox/vector_tile.hpp b/include/mapbox/vector_tile.hpp
index c61640b..0e8c672 100644
--- a/include/mapbox/vector_tile.hpp
+++ b/include/mapbox/vector_tile.hpp
@@ -66,12 +66,13 @@ layer_map decode_tile(std::string const& buffer)
while (auto layer = tile.next_layer())
{
mapbox::feature::feature_collection fc;
+ fc.reserve(layer.num_features());
while (auto feature = layer.next_feature())
{
auto f = extract_feature(feature);
if (!f.geometry.template is())
{
- fc.push_back(f);
+ fc.push_back(std::move(f));
}
}
```
/cc @flippmoke to review and apply if this looks good.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.