diff options
author | Jesse Crocker <jesse@gaiagps.com> | 2017-09-08 13:56:11 -0700 |
---|---|---|
committer | Asheem Mamoowala <asheem.mamoowala@mapbox.com> | 2017-09-26 10:55:40 -0700 |
commit | a06f4849bc58cbe21b001f1f15fd0828bde9b79b (patch) | |
tree | d69f9162191af34cb8ab32668af9a41f2351e7ff | |
parent | 9eba7d8b3e0db0fb4592218bf0e33841933bcd3e (diff) | |
download | qtlocation-mapboxgl-a06f4849bc58cbe21b001f1f15fd0828bde9b79b.tar.gz |
[core] Move *TileID hashing to separate impl
-rw-r--r-- | cmake/core-files.cmake | 3 | ||||
-rw-r--r-- | include/mbgl/tile/tile_id.hpp (renamed from src/mbgl/tile/tile_id.hpp) | 33 | ||||
-rw-r--r-- | src/mbgl/tile/tile_id_hash.cpp | 29 |
3 files changed, 41 insertions, 24 deletions
diff --git a/cmake/core-files.cmake b/cmake/core-files.cmake index 49697a5c29..c34a0724f4 100644 --- a/cmake/core-files.cmake +++ b/cmake/core-files.cmake @@ -490,6 +490,7 @@ set(MBGL_CORE_FILES src/mbgl/text/shaping.hpp # tile + include/mbgl/tile/tile_id.hpp src/mbgl/tile/geojson_tile.cpp src/mbgl/tile/geojson_tile.hpp src/mbgl/tile/geometry_tile.cpp @@ -506,7 +507,7 @@ set(MBGL_CORE_FILES src/mbgl/tile/tile.hpp src/mbgl/tile/tile_cache.cpp src/mbgl/tile/tile_cache.hpp - src/mbgl/tile/tile_id.hpp + src/mbgl/tile/tile_id_hash.cpp src/mbgl/tile/tile_id_io.cpp src/mbgl/tile/tile_loader.hpp src/mbgl/tile/tile_loader_impl.hpp diff --git a/src/mbgl/tile/tile_id.hpp b/include/mbgl/tile/tile_id.hpp index 811158e9b9..0457dd3a07 100644 --- a/src/mbgl/tile/tile_id.hpp +++ b/include/mbgl/tile/tile_id.hpp @@ -4,11 +4,11 @@ #include <cstdint> #include <array> +#include <tuple> #include <forward_list> #include <algorithm> #include <iosfwd> #include <cassert> -#include <boost/functional/hash.hpp> namespace mbgl { @@ -244,32 +244,19 @@ inline float UnwrappedTileID::pixelsToTileUnits(const float pixelValue, const fl 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::CanonicalTileID> { + size_t operator()(const mbgl::CanonicalTileID& id) const; }; -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::UnwrappedTileID> { + size_t operator()(const mbgl::UnwrappedTileID& id) const; }; -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; - } +template <> +struct hash<mbgl::OverscaledTileID> { + size_t operator()(const mbgl::OverscaledTileID& id) const; }; } // namespace std diff --git a/src/mbgl/tile/tile_id_hash.cpp b/src/mbgl/tile/tile_id_hash.cpp new file mode 100644 index 0000000000..4a1f185817 --- /dev/null +++ b/src/mbgl/tile/tile_id_hash.cpp @@ -0,0 +1,29 @@ +#include <mbgl/tile/tile_id.hpp> + +#include <boost/functional/hash.hpp> + +namespace std { + +size_t hash<mbgl::CanonicalTileID>::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; +} + +size_t hash<mbgl::UnwrappedTileID>::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; +} + +size_t hash<mbgl::OverscaledTileID>::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 |