From 37cb2bd756104923c8a055277a9d598710943e9f Mon Sep 17 00:00:00 2001 From: Lucas Wojciechowski Date: Mon, 19 Sep 2016 17:26:25 -0700 Subject: [core] Convert uses of std::set to std::unordered_set (#6325) * src/mbgl/annotation/annotation_manager.hpp * src/mbgl/algorithm/update_renderables.hpp * src/mbgl/geometry/glyph_atlas.hpp * src/mbgl/renderer/painter.cpp and src/mbgl/renderer/render_item.hpp * src/mbgl/renderer/symbol_bucket.hpp and src/mbgl/text/glyph_store.hpp * src/mbgl/sprite/sprite_atlas.hpp * include/mbgl/storage/network_status.hpp * src/mbgl/text/collision_tile.cpp * src/mbgl/style/update_batch.hpp * platform/default/mbgl/storage/offline_download.hpp * Add GlyphRangeSet typedef * Fix whitespace & unused imports --- src/mbgl/algorithm/update_renderables.hpp | 4 ++-- src/mbgl/annotation/annotation_manager.hpp | 6 +++--- src/mbgl/layout/symbol_layout.hpp | 4 ++-- src/mbgl/renderer/painter.cpp | 3 ++- src/mbgl/renderer/render_item.hpp | 4 ++-- src/mbgl/renderer/symbol_bucket.hpp | 1 - src/mbgl/sprite/sprite_atlas.hpp | 4 ++-- src/mbgl/storage/network_status.cpp | 2 +- src/mbgl/style/update_batch.hpp | 4 ++-- src/mbgl/text/collision_tile.cpp | 2 +- src/mbgl/text/glyph_atlas.cpp | 2 +- src/mbgl/text/glyph_atlas.hpp | 6 +++--- src/mbgl/text/glyph_range.hpp | 10 ++++++++++ 13 files changed, 31 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/mbgl/algorithm/update_renderables.hpp b/src/mbgl/algorithm/update_renderables.hpp index 5a6a26f987..fe2dc2c570 100644 --- a/src/mbgl/algorithm/update_renderables.hpp +++ b/src/mbgl/algorithm/update_renderables.hpp @@ -4,7 +4,7 @@ #include #include -#include +#include namespace mbgl { namespace algorithm { @@ -21,7 +21,7 @@ void updateRenderables(GetTileFn getTile, const IdealTileIDs& idealTileIDs, const Range& zoomRange, const uint8_t dataTileZoom) { - std::set checked; + std::unordered_set checked; bool covered; int32_t overscaledZ; diff --git a/src/mbgl/annotation/annotation_manager.hpp b/src/mbgl/annotation/annotation_manager.hpp index b4959964f6..856aeeed72 100644 --- a/src/mbgl/annotation/annotation_manager.hpp +++ b/src/mbgl/annotation/annotation_manager.hpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include namespace mbgl { @@ -72,8 +72,8 @@ private: SymbolAnnotationTree symbolTree; SymbolAnnotationMap symbolAnnotations; ShapeAnnotationMap shapeAnnotations; - std::set obsoleteShapeAnnotationLayers; - std::set tiles; + std::unordered_set obsoleteShapeAnnotationLayers; + std::unordered_set tiles; SpriteAtlas spriteAtlas; }; diff --git a/src/mbgl/layout/symbol_layout.hpp b/src/mbgl/layout/symbol_layout.hpp index db27f1b817..c4e6455794 100644 --- a/src/mbgl/layout/symbol_layout.hpp +++ b/src/mbgl/layout/symbol_layout.hpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include namespace mbgl { @@ -88,7 +88,7 @@ private: bool sdfIcons = false; bool iconsNeedLinear = false; - std::set ranges; + GlyphRangeSet ranges; std::vector symbolInstances; std::vector features; }; diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp index 915f83f01b..9822b6b914 100644 --- a/src/mbgl/renderer/painter.cpp +++ b/src/mbgl/renderer/painter.cpp @@ -31,6 +31,7 @@ #include #include #include +#include namespace mbgl { @@ -80,7 +81,7 @@ void Painter::render(const Style& style, const FrameData& frame_, SpriteAtlas& a RenderData renderData = style.getRenderData(frame.debugOptions); const std::vector& order = renderData.order; - const std::set& sources = renderData.sources; + const std::unordered_set& sources = renderData.sources; const Color& background = renderData.backgroundColor; // Update the default matrices to the current viewport dimensions. diff --git a/src/mbgl/renderer/render_item.hpp b/src/mbgl/renderer/render_item.hpp index 82ea897047..b4b1f4aec2 100644 --- a/src/mbgl/renderer/render_item.hpp +++ b/src/mbgl/renderer/render_item.hpp @@ -2,7 +2,7 @@ #include -#include +#include #include namespace mbgl { @@ -31,7 +31,7 @@ public: class RenderData { public: Color backgroundColor; - std::set sources; + std::unordered_set sources; std::vector order; }; diff --git a/src/mbgl/renderer/symbol_bucket.hpp b/src/mbgl/renderer/symbol_bucket.hpp index 8f0c21bc95..ad53cd6630 100644 --- a/src/mbgl/renderer/symbol_bucket.hpp +++ b/src/mbgl/renderer/symbol_bucket.hpp @@ -10,7 +10,6 @@ #include #include -#include #include namespace mbgl { diff --git a/src/mbgl/sprite/sprite_atlas.hpp b/src/mbgl/sprite/sprite_atlas.hpp index d23d3a0fd1..7a3c2c8b45 100644 --- a/src/mbgl/sprite/sprite_atlas.hpp +++ b/src/mbgl/sprite/sprite_atlas.hpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include @@ -140,7 +140,7 @@ private: std::recursive_mutex mtx; BinPack bin; std::map images; - std::set uninitialized; + std::unordered_set uninitialized; std::unique_ptr data; std::atomic dirtyFlag; bool fullUploadRequired = true; diff --git a/src/mbgl/storage/network_status.cpp b/src/mbgl/storage/network_status.cpp index 1ef5619bd6..1bd392d578 100644 --- a/src/mbgl/storage/network_status.cpp +++ b/src/mbgl/storage/network_status.cpp @@ -11,7 +11,7 @@ namespace mbgl { std::atomic NetworkStatus::online(true); std::mutex NetworkStatus::mtx; -std::set NetworkStatus::observers; +std::unordered_set NetworkStatus::observers; NetworkStatus::Status NetworkStatus::Get() { if (online) { diff --git a/src/mbgl/style/update_batch.hpp b/src/mbgl/style/update_batch.hpp index ee82c98fda..562df52afa 100644 --- a/src/mbgl/style/update_batch.hpp +++ b/src/mbgl/style/update_batch.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include namespace mbgl { @@ -8,7 +8,7 @@ namespace style { class UpdateBatch { public: - std::set sourceIDs; + std::unordered_set sourceIDs; }; } // namespace style diff --git a/src/mbgl/text/collision_tile.cpp b/src/mbgl/text/collision_tile.cpp index 982dff1688..32a1a5474a 100644 --- a/src/mbgl/text/collision_tile.cpp +++ b/src/mbgl/text/collision_tile.cpp @@ -156,7 +156,7 @@ Box CollisionTile::getTreeBox(const Point& anchor, const CollisionBox& bo std::vector CollisionTile::queryRenderedSymbols(const mapbox::geometry::box& box, const float scale) { std::vector result; - std::unordered_map> sourceLayerFeatures; + std::unordered_map> sourceLayerFeatures; auto anchor = util::matrixMultiply(rotationMatrix, convertPoint(box.min)); CollisionBox queryBox(anchor, 0, 0, box.max.x - box.min.x, box.max.y - box.min.y, scale); diff --git a/src/mbgl/text/glyph_atlas.cpp b/src/mbgl/text/glyph_atlas.cpp index 9e92e3e81e..f46c156b20 100644 --- a/src/mbgl/text/glyph_atlas.cpp +++ b/src/mbgl/text/glyph_atlas.cpp @@ -39,7 +39,7 @@ void GlyphAtlas::requestGlyphRange(const FontStack& fontStack, const GlyphRange& std::make_unique(this, fontStack, range, observer, fileSource)); } -bool GlyphAtlas::hasGlyphRanges(const FontStack& fontStack, const std::set& glyphRanges) { +bool GlyphAtlas::hasGlyphRanges(const FontStack& fontStack, const GlyphRangeSet& glyphRanges) { if (glyphRanges.empty()) { return true; } diff --git a/src/mbgl/text/glyph_atlas.hpp b/src/mbgl/text/glyph_atlas.hpp index ca88d16f8b..5c6cbf45f0 100644 --- a/src/mbgl/text/glyph_atlas.hpp +++ b/src/mbgl/text/glyph_atlas.hpp @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include #include @@ -41,7 +41,7 @@ public: // made and when the glyph if finally parsed, it gets added to the respective // GlyphSet and a signal is emitted to notify the observers. This method // can be called from any thread. - bool hasGlyphRanges(const FontStack&, const std::set&); + bool hasGlyphRanges(const FontStack&, const GlyphRangeSet&); void setURL(const std::string &url) { glyphURL = url; @@ -95,7 +95,7 @@ private: GlyphValue(Rect rect_, uintptr_t id) : rect(std::move(rect_)), ids({ id }) {} Rect rect; - std::set ids; + std::unordered_set ids; }; std::mutex mtx; diff --git a/src/mbgl/text/glyph_range.hpp b/src/mbgl/text/glyph_range.hpp index 644046d7f8..aa11b35f5e 100644 --- a/src/mbgl/text/glyph_range.hpp +++ b/src/mbgl/text/glyph_range.hpp @@ -2,9 +2,19 @@ #include #include +#include +#include namespace mbgl { typedef std::pair GlyphRange; +struct GlyphRangeHash { + std::size_t operator()(const GlyphRange& glyphRange) const { + return boost::hash_value(glyphRange); + } +}; + +typedef std::unordered_set GlyphRangeSet; + } // end namespace mbgl -- cgit v1.2.1