mapbox / mapbox/vector-tile

2.x branch optimization

Open
#32 0 comments 0 reactions 1 assignee View on GitHub

@flippmoke is already working on this.

Since Jan 17, 2018.

2.x
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.