summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrad Leege <bleege@gmail.com>2016-09-12 15:45:57 -0700
committerBrad Leege <bleege@gmail.com>2016-09-14 16:40:20 -0700
commitd0f9ba499831a7412e51bd45141c9637ea484fde (patch)
tree187d7bfbb0c31e294dd9879dbb12a1e54a25903b /src
parenta9f5224664905ac28a372be6aad429a31790df03 (diff)
downloadqtlocation-mapboxgl-d0f9ba499831a7412e51bd45141c9637ea484fde.tar.gz
[core] #3980 - Switching Core GL instances of map to unordered_map
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/algorithm/generate_clip_ids.hpp8
-rw-r--r--src/mbgl/geometry/line_atlas.hpp4
-rw-r--r--src/mbgl/gl/gl.cpp8
-rw-r--r--src/mbgl/renderer/symbol_bucket.hpp1
-rw-r--r--src/mbgl/style/paint_property.hpp6
-rw-r--r--src/mbgl/tile/tile_id.hpp34
-rw-r--r--src/mbgl/tile/vector_tile.cpp6
-rw-r--r--src/mbgl/util/merge_lines.cpp2
-rw-r--r--src/mbgl/util/merge_lines.hpp10
9 files changed, 56 insertions, 23 deletions
diff --git a/src/mbgl/algorithm/generate_clip_ids.hpp b/src/mbgl/algorithm/generate_clip_ids.hpp
index 0454c99524..d917b398af 100644
--- a/src/mbgl/algorithm/generate_clip_ids.hpp
+++ b/src/mbgl/algorithm/generate_clip_ids.hpp
@@ -3,9 +3,9 @@
#include <mbgl/tile/tile_id.hpp>
#include <mbgl/util/clip_id.hpp>
-#include <set>
+#include <unordered_set>
#include <vector>
-#include <map>
+#include <unordered_map>
namespace mbgl {
namespace algorithm {
@@ -17,12 +17,12 @@ private:
void add(const CanonicalTileID &p);
bool operator==(const Leaf &other) const;
- std::set<CanonicalTileID> children;
+ std::unordered_set<CanonicalTileID> children;
ClipID& clip;
};
uint8_t bit_offset = 0;
- std::multimap<UnwrappedTileID, Leaf> pool;
+ std::unordered_multimap<UnwrappedTileID, Leaf> pool;
public:
template <typename Renderables>
diff --git a/src/mbgl/geometry/line_atlas.hpp b/src/mbgl/geometry/line_atlas.hpp
index a2bda71863..7658ed33c1 100644
--- a/src/mbgl/geometry/line_atlas.hpp
+++ b/src/mbgl/geometry/line_atlas.hpp
@@ -5,7 +5,7 @@
#include <mbgl/util/optional.hpp>
#include <vector>
-#include <map>
+#include <unordered_map>
namespace mbgl {
@@ -47,7 +47,7 @@ private:
bool dirty;
mbgl::optional<gl::UniqueTexture> texture;
int nextRow = 0;
- std::map<size_t, LinePatternPos> positions;
+ std::unordered_map<size_t, LinePatternPos> positions;
};
} // namespace mbgl
diff --git a/src/mbgl/gl/gl.cpp b/src/mbgl/gl/gl.cpp
index 7747717c63..309785140f 100644
--- a/src/mbgl/gl/gl.cpp
+++ b/src/mbgl/gl/gl.cpp
@@ -4,7 +4,7 @@
#include <cassert>
#include <iostream>
-#include <map>
+#include <unordered_map>
#include <mutex>
namespace mbgl {
@@ -98,15 +98,15 @@ void checkError(const char *cmd, const char *file, int line) {
#undef glBufferData
static unsigned int currentUsedBytes = 0;
static GLint currentBoundTexture = 0;
-static std::map<GLint, unsigned int> bindingToSizeMap;
+static std::unordered_map<GLint, unsigned int> bindingToSizeMap;
static GLuint currentArrayBuffer = 0;
static GLuint currentElementArrayBuffer = 0;
-static std::map<GLint, GLsizeiptr> bufferBindingToSizeMap;
+static std::unordered_map<GLint, GLsizeiptr> bufferBindingToSizeMap;
static unsigned int currentUsedBufferBytes = 0;
static unsigned int largestAmountUsedSoFar = 0;
-static std::map<GLuint, GLuint> vertexArrayToArrayBufferMap;
+static std::unordered_map<GLuint, GLuint> vertexArrayToArrayBufferMap;
static GLuint currentVertexArray = 0;
static std::mutex gDebugMutex;
diff --git a/src/mbgl/renderer/symbol_bucket.hpp b/src/mbgl/renderer/symbol_bucket.hpp
index 8f0c21bc95..988cf5db27 100644
--- a/src/mbgl/renderer/symbol_bucket.hpp
+++ b/src/mbgl/renderer/symbol_bucket.hpp
@@ -45,7 +45,6 @@ public:
const bool iconsNeedLinear;
private:
- friend class SymbolLayout;
typedef ElementGroup<2> TextElementGroup;
typedef ElementGroup<4> IconElementGroup;
diff --git a/src/mbgl/style/paint_property.hpp b/src/mbgl/style/paint_property.hpp
index 070751616e..4a620706ec 100644
--- a/src/mbgl/style/paint_property.hpp
+++ b/src/mbgl/style/paint_property.hpp
@@ -10,7 +10,7 @@
#include <mbgl/util/interpolate.hpp>
#include <mbgl/util/rapidjson.hpp>
-#include <map>
+#include <unordered_map>
#include <utility>
namespace mbgl {
@@ -96,8 +96,8 @@ public:
private:
T defaultValue;
- std::map<ClassID, PropertyValue<T>> values;
- std::map<ClassID, TransitionOptions> transitions;
+ std::unordered_map<ClassID, PropertyValue<T>> values;
+ std::unordered_map<ClassID, TransitionOptions> transitions;
struct CascadedValue {
CascadedValue(std::unique_ptr<CascadedValue> prior_,
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_,
diff --git a/src/mbgl/util/merge_lines.cpp b/src/mbgl/util/merge_lines.cpp
index 0f2a955e95..663f757dca 100644
--- a/src/mbgl/util/merge_lines.cpp
+++ b/src/mbgl/util/merge_lines.cpp
@@ -5,7 +5,7 @@
namespace mbgl {
namespace util {
-using Index = std::map<size_t, unsigned int>;
+using Index = std::unordered_map<size_t, unsigned int>;
unsigned int mergeFromRight(std::vector<SymbolFeature> &features,
Index &rightIndex,
diff --git a/src/mbgl/util/merge_lines.hpp b/src/mbgl/util/merge_lines.hpp
index 8db8c284cd..bb4c01f6a2 100644
--- a/src/mbgl/util/merge_lines.hpp
+++ b/src/mbgl/util/merge_lines.hpp
@@ -1,6 +1,6 @@
#pragma once
-#include <map>
+#include <unordered_map>
#include <string>
#include <vector>
#include <mbgl/layout/symbol_layout.hpp>
@@ -9,15 +9,15 @@ namespace mbgl {
namespace util {
unsigned int mergeFromRight(std::vector<SymbolFeature> &features,
- std::map<std::string, unsigned int> &rightIndex,
- std::map<std::string, unsigned int>::iterator left,
+ std::unordered_map<std::string, unsigned int> &rightIndex,
+ std::unordered_map<std::string, unsigned int>::iterator left,
std::string &rightKey,
GeometryCollection &geom);
unsigned int mergeFromLeft(std::vector<SymbolFeature> &features,
- std::map<std::string, unsigned int> &leftIndex,
+ std::unordered_map<std::string, unsigned int> &leftIndex,
std::string &leftKey,
- std::map<std::string, unsigned int>::iterator right,
+ std::unordered_map<std::string, unsigned int>::iterator right,
GeometryCollection &geom);
void mergeLines(std::vector<SymbolFeature> &features);