From e6e1e15f950dc246e609cf4acf5b9d6ca13f8806 Mon Sep 17 00:00:00 2001 From: Mikhail Pozdnyakov Date: Wed, 24 Jul 2019 16:49:58 +0300 Subject: [core] Simplfy ToGeometryCollection --- src/mbgl/tile/geometry_tile_data.hpp | 39 +++++++----------------------------- 1 file changed, 7 insertions(+), 32 deletions(-) diff --git a/src/mbgl/tile/geometry_tile_data.hpp b/src/mbgl/tile/geometry_tile_data.hpp index 203afcace7..a06e2be835 100644 --- a/src/mbgl/tile/geometry_tile_data.hpp +++ b/src/mbgl/tile/geometry_tile_data.hpp @@ -97,31 +97,16 @@ struct ToGeometryCollection { return { { geom } }; } GeometryCollection operator()(const mapbox::geometry::multi_point& geom) const { - GeometryCoordinates coordinates; - coordinates.reserve(geom.size()); - for (const auto& point : geom) { - coordinates.emplace_back(point); - } - return { coordinates }; + return { geom }; } GeometryCollection operator()(const mapbox::geometry::line_string& geom) const { - GeometryCoordinates coordinates; - coordinates.reserve(geom.size()); - for (const auto& point : geom) { - coordinates.emplace_back(point); - } - return { coordinates }; + return { geom }; } GeometryCollection operator()(const mapbox::geometry::multi_line_string& geom) const { GeometryCollection collection; collection.reserve(geom.size()); for (const auto& ring : geom) { - GeometryCoordinates coordinates; - coordinates.reserve(ring.size()); - for (const auto& point : ring) { - coordinates.emplace_back(point); - } - collection.push_back(std::move(coordinates)); + collection.emplace_back(ring); } return collection; } @@ -129,25 +114,15 @@ struct ToGeometryCollection { GeometryCollection collection; collection.reserve(geom.size()); for (const auto& ring : geom) { - GeometryCoordinates coordinates; - coordinates.reserve(ring.size()); - for (const auto& point : ring) { - coordinates.emplace_back(point); - } - collection.push_back(std::move(coordinates)); + collection.emplace_back(ring); } return collection; } GeometryCollection operator()(const mapbox::geometry::multi_polygon& geom) const { GeometryCollection collection; - for (auto& polygon : geom) { - for (auto& ring : polygon) { - GeometryCoordinates coordinates; - coordinates.reserve(ring.size()); - for (auto& point : ring) { - coordinates.emplace_back(point); - } - collection.push_back(std::move(coordinates)); + for (const auto& polygon : geom) { + for (const auto& ring : polygon) { + collection.emplace_back(ring); } } return collection; -- cgit v1.2.1