[core] #3980 - Switching Core GL instances of map to unordered_map

This commit is contained in:
Brad Leege
2016-09-12 15:45:57 -07:00
parent a9f5224664
commit d0f9ba4998
11 changed files with 60 additions and 27 deletions

View File

@@ -30,7 +30,7 @@
#import <mbgl/util/constants.hpp>
#import <mbgl/util/chrono.hpp>
#import <map>
#import <unordered_map>
#import <unordered_set>
#import "NSBundle+MGLAdditions.h"
@@ -102,7 +102,7 @@ enum { MGLAnnotationTagNotFound = UINT32_MAX };
/// Mapping from an annotation tag to metadata about that annotation, including
/// the annotation itself.
typedef std::map<MGLAnnotationTag, MGLAnnotationContext> MGLAnnotationContextMap;
typedef std::unordered_map<MGLAnnotationTag, MGLAnnotationContext> MGLAnnotationContextMap;
/// Returns an NSImage for the default marker image.
NSImage *MGLDefaultMarkerImage() {

View File

@@ -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>

View File

@@ -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

View File

@@ -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;

View File

@@ -45,7 +45,6 @@ public:
const bool iconsNeedLinear;
private:
friend class SymbolLayout;
typedef ElementGroup<2> TextElementGroup;
typedef ElementGroup<4> IconElementGroup;

View File

@@ -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_,

View File

@@ -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

View File

@@ -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_,

View File

@@ -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,

View File

@@ -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);

View File

@@ -6,14 +6,14 @@
#include <mbgl/util/variant.hpp>
#include <string>
#include <map>
#include <unordered_map>
namespace mbgl {
namespace style {
namespace conversion {
class Value;
using ValueMap = std::map<std::string, Value>;
using ValueMap = std::unordered_map<std::string, Value>;
using ValueVector = std::vector<Value>;
class Value : public mbgl::variant<std::string, float, bool, ValueMap, ValueVector> {
using variant::variant;