diff options
author | Brad Leege <bleege@gmail.com> | 2016-09-12 15:45:57 -0700 |
---|---|---|
committer | Brad Leege <bleege@gmail.com> | 2016-09-14 16:40:20 -0700 |
commit | d0f9ba499831a7412e51bd45141c9637ea484fde (patch) | |
tree | 187d7bfbb0c31e294dd9879dbb12a1e54a25903b /src/mbgl/tile | |
parent | a9f5224664905ac28a372be6aad429a31790df03 (diff) | |
download | qtlocation-mapboxgl-d0f9ba499831a7412e51bd45141c9637ea484fde.tar.gz |
[core] #3980 - Switching Core GL instances of map to unordered_map
Diffstat (limited to 'src/mbgl/tile')
-rw-r--r-- | src/mbgl/tile/tile_id.hpp | 34 | ||||
-rw-r--r-- | src/mbgl/tile/vector_tile.cpp | 6 |
2 files changed, 37 insertions, 3 deletions
diff --git a/src/mbgl/tile/tile_id.hpp b/src/mbgl/tile/tile_id.hpp index f561db9a4d..88b01269e5 100644 --- a/src/mbgl/tile/tile_id.hpp +++ b/src/mbgl/tile/tile_id.hpp @@ -8,6 +8,7 @@ #include <algorithm> #include <iosfwd> #include <cassert> +#include <boost/functional/hash.hpp> namespace mbgl { @@ -254,3 +255,36 @@ inline float UnwrappedTileID::pixelsToTileUnits(const float pixelValue, const fl } } // namespace mbgl + +namespace std { + +template <> struct hash<mbgl::CanonicalTileID> { + size_t operator()(const mbgl::CanonicalTileID &id) const { + std::size_t seed = 0; + boost::hash_combine(seed, id.x); + boost::hash_combine(seed, id.y); + boost::hash_combine(seed, id.z); + return seed; + } +}; + +template <> struct hash<mbgl::UnwrappedTileID> { + size_t operator()(const mbgl::UnwrappedTileID &id) const { + std::size_t seed = 0; + boost::hash_combine(seed, std::hash<mbgl::CanonicalTileID>{}(id.canonical)); + boost::hash_combine(seed, id.wrap); + return seed; + } +}; + +template <> struct hash<mbgl::OverscaledTileID> { + size_t operator()(const mbgl::OverscaledTileID &id) const { + std::size_t seed = 0; + boost::hash_combine(seed, std::hash<mbgl::CanonicalTileID>{}(id.canonical)); + boost::hash_combine(seed, id.overscaledZ); + return seed; + } +}; + +} // namespace std + diff --git a/src/mbgl/tile/vector_tile.cpp b/src/mbgl/tile/vector_tile.cpp index 4a1f60711c..bde0b4f63e 100644 --- a/src/mbgl/tile/vector_tile.cpp +++ b/src/mbgl/tile/vector_tile.cpp @@ -5,7 +5,7 @@ #include <protozero/pbf_reader.hpp> -#include <map> +#include <unordered_map> #include <unordered_map> #include <functional> #include <utility> @@ -49,7 +49,7 @@ private: std::string name; uint32_t version = 1; uint32_t extent = 4096; - std::map<std::string, uint32_t> keysMap; + std::unordered_map<std::string, uint32_t> keysMap; std::vector<std::reference_wrapper<const std::string>> keys; std::vector<Value> values; std::vector<protozero::pbf_reader> features; @@ -68,7 +68,7 @@ public: private: std::shared_ptr<const std::string> data; mutable bool parsed = false; - mutable std::map<std::string, VectorTileLayer> layers; + mutable std::unordered_map<std::string, VectorTileLayer> layers; }; VectorTile::VectorTile(const OverscaledTileID& id_, |