[core] don't use <boost/functional/hash.hpp> to avoid <locale> include
This commit is contained in:
@@ -726,6 +726,7 @@ src/mbgl/util/geo.cpp
|
||||
src/mbgl/util/geojson_impl.cpp
|
||||
src/mbgl/util/grid_index.cpp
|
||||
src/mbgl/util/grid_index.hpp
|
||||
src/mbgl/util/hash.hpp
|
||||
src/mbgl/util/http_header.cpp
|
||||
src/mbgl/util/http_header.hpp
|
||||
src/mbgl/util/http_timeout.cpp
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
#include <mbgl/gl/context.hpp>
|
||||
#include <mbgl/util/logging.hpp>
|
||||
#include <mbgl/util/platform.hpp>
|
||||
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include <mbgl/util/hash.hpp>
|
||||
|
||||
#include <sstream>
|
||||
#include <cmath>
|
||||
@@ -22,7 +21,7 @@ LinePatternPos LineAtlas::getDashPosition(const std::vector<float>& dasharray,
|
||||
size_t key = patternCap == LinePatternCap::Round ? std::numeric_limits<size_t>::min()
|
||||
: std::numeric_limits<size_t>::max();
|
||||
for (const float part : dasharray) {
|
||||
boost::hash_combine<float>(key, part);
|
||||
util::hash_combine<float>(key, part);
|
||||
}
|
||||
|
||||
// Note: We're not handling hash collisions here.
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include <mbgl/layout/merge_lines.hpp>
|
||||
#include <mbgl/layout/symbol_feature.hpp>
|
||||
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include <mbgl/util/hash.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace util {
|
||||
@@ -43,10 +42,7 @@ size_t mergeFromLeft(std::vector<SymbolFeature>& features,
|
||||
}
|
||||
|
||||
size_t getKey(const std::u16string& text, const GeometryCoordinate& coord) {
|
||||
auto hash = std::hash<std::u16string>()(text);
|
||||
boost::hash_combine(hash, coord.x);
|
||||
boost::hash_combine(hash, coord.y);
|
||||
return hash;
|
||||
return util::hash(text, coord.x, coord.y);
|
||||
}
|
||||
|
||||
void mergeLines(std::vector<SymbolFeature>& features) {
|
||||
|
||||
@@ -115,7 +115,7 @@ MBGL_CONSTEXPR WritingModeType operator~(WritingModeType value) {
|
||||
return WritingModeType(~mbgl::underlying_type(value));
|
||||
}
|
||||
|
||||
using GlyphDependencies = std::map<FontStack,GlyphIDs>;
|
||||
using GlyphRangeDependencies = std::map<FontStack,GlyphRangeSet>;
|
||||
using GlyphDependencies = std::map<FontStack, GlyphIDs>;
|
||||
using GlyphRangeDependencies = std::map<FontStack, std::unordered_set<GlyphRange>>;
|
||||
|
||||
} // end namespace mbgl
|
||||
|
||||
@@ -31,7 +31,7 @@ void GlyphManager::getGlyphs(GlyphRequestor& requestor, GlyphDependencies glyphD
|
||||
Entry& entry = entries[fontStack];
|
||||
|
||||
const GlyphIDs& glyphIDs = dependency.second;
|
||||
GlyphRangeSet ranges;
|
||||
std::unordered_set<GlyphRange> ranges;
|
||||
for (const auto& glyphID : glyphIDs) {
|
||||
if (localGlyphRasterizer->canRasterizeGlyph(fontStack, glyphID)) {
|
||||
if (entry.glyphs.find(glyphID) == entry.glyphs.end()) {
|
||||
|
||||
@@ -3,21 +3,24 @@
|
||||
#include <utility>
|
||||
#include <cstdint>
|
||||
#include <unordered_set>
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include <mbgl/util/hash.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
using GlyphRange = std::pair<uint16_t, uint16_t>;
|
||||
|
||||
struct GlyphRangeHash {
|
||||
std::size_t operator()(const GlyphRange& glyphRange) const {
|
||||
return boost::hash_value(glyphRange);
|
||||
}
|
||||
};
|
||||
|
||||
using GlyphRangeSet = std::unordered_set<GlyphRange, GlyphRangeHash>;
|
||||
|
||||
constexpr uint32_t GLYPHS_PER_GLYPH_RANGE = 256;
|
||||
constexpr uint32_t GLYPH_RANGES_PER_FONT_STACK = 256;
|
||||
|
||||
} // end namespace mbgl
|
||||
|
||||
namespace std {
|
||||
|
||||
template <>
|
||||
struct hash<mbgl::GlyphRange> {
|
||||
std::size_t operator()(const mbgl::GlyphRange& range) const {
|
||||
return mbgl::util::hash(range.first, range.second);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
|
||||
@@ -1,28 +1,27 @@
|
||||
#include <mbgl/tile/tile_id.hpp>
|
||||
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include <mbgl/util/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);
|
||||
mbgl::util::hash_combine(seed, id.x);
|
||||
mbgl::util::hash_combine(seed, id.y);
|
||||
mbgl::util::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);
|
||||
mbgl::util::hash_combine(seed, std::hash<mbgl::CanonicalTileID>{}(id.canonical));
|
||||
mbgl::util::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);
|
||||
mbgl::util::hash_combine(seed, std::hash<mbgl::CanonicalTileID>{}(id.canonical));
|
||||
mbgl::util::hash_combine(seed, id.overscaledZ);
|
||||
return seed;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include <mbgl/util/font_stack.hpp>
|
||||
#include <mbgl/util/logging.hpp>
|
||||
#include <mbgl/style/layers/symbol_layer_impl.hpp>
|
||||
#include <mbgl/util/hash.hpp>
|
||||
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
@@ -14,7 +14,11 @@ std::string fontStackToString(const FontStack& fontStack) {
|
||||
}
|
||||
|
||||
FontStackHash FontStackHasher::operator()(const FontStack& fontStack) const {
|
||||
return boost::hash_range(fontStack.begin(), fontStack.end());
|
||||
std::size_t seed = 0;
|
||||
for (const auto& font : fontStack) {
|
||||
util::hash_combine(seed, font);
|
||||
}
|
||||
return seed;
|
||||
}
|
||||
|
||||
std::set<FontStack> fontStacks(const std::vector<Immutable<style::Layer::Impl>>& layers) {
|
||||
|
||||
23
src/mbgl/util/hash.hpp
Normal file
23
src/mbgl/util/hash.hpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/util/ignore.hpp>
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace mbgl {
|
||||
namespace util {
|
||||
|
||||
template <class T>
|
||||
inline void hash_combine(std::size_t& seed, const T& v) {
|
||||
seed ^= std::hash<T>()(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
inline std::size_t hash(Args&&... args) {
|
||||
std::size_t seed = 0;
|
||||
ignore({ (hash_combine(seed, args), 0)... });
|
||||
return seed;
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace mbgl
|
||||
Reference in New Issue
Block a user