mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-05 09:55:41 +02:00
Reserve storage when decoding
This commit is contained in:
@@ -224,6 +224,7 @@ bool mvt_tile::decode(const std::string &message, bool &was_compressed) {
|
|||||||
case 2: /* tag */
|
case 2: /* tag */
|
||||||
{
|
{
|
||||||
auto pi = feature_reader.get_packed_uint32();
|
auto pi = feature_reader.get_packed_uint32();
|
||||||
|
feature.tags.reserve(std::distance(pi.first, pi.second));
|
||||||
for (auto it = pi.first; it != pi.second; ++it) {
|
for (auto it = pi.first; it != pi.second; ++it) {
|
||||||
feature.tags.push_back(*it);
|
feature.tags.push_back(*it);
|
||||||
}
|
}
|
||||||
@@ -237,6 +238,7 @@ bool mvt_tile::decode(const std::string &message, bool &was_compressed) {
|
|||||||
case 4: /* geometry */
|
case 4: /* geometry */
|
||||||
{
|
{
|
||||||
auto pi = feature_reader.get_packed_uint32();
|
auto pi = feature_reader.get_packed_uint32();
|
||||||
|
geoms.reserve(std::distance(pi.first, pi.second));
|
||||||
for (auto it = pi.first; it != pi.second; ++it) {
|
for (auto it = pi.first; it != pi.second; ++it) {
|
||||||
geoms.push_back(*it);
|
geoms.push_back(*it);
|
||||||
}
|
}
|
||||||
@@ -250,6 +252,7 @@ bool mvt_tile::decode(const std::string &message, bool &was_compressed) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
long long px = 0, py = 0;
|
long long px = 0, py = 0;
|
||||||
|
feature.geometry.reserve(geoms.size()); // probably not quite right, but still plausible
|
||||||
for (size_t g = 0; g < geoms.size(); g++) {
|
for (size_t g = 0; g < geoms.size(); g++) {
|
||||||
uint32_t geom = geoms[g];
|
uint32_t geom = geoms[g];
|
||||||
uint32_t op = geom & 7;
|
uint32_t op = geom & 7;
|
||||||
|
|||||||
Reference in New Issue
Block a user