diff --git a/include/llmr/style/sprite.hpp b/include/llmr/style/sprite.hpp index 4f902d77a..07f5903e5 100644 --- a/include/llmr/style/sprite.hpp +++ b/include/llmr/style/sprite.hpp @@ -1,14 +1,14 @@ #ifndef LLMR_STYLE_SPRITE #define LLMR_STYLE_SPRITE -#include +#include +#include + #include #include #include #include - -#include -#include +#include namespace llmr { @@ -55,7 +55,7 @@ private: std::string body; std::string image; std::atomic loaded; - std::map pos; + std::unordered_map pos; const SpritePosition empty; }; diff --git a/src/style/sprite.cpp b/src/style/sprite.cpp index a0070b288..1b6905d74 100644 --- a/src/style/sprite.cpp +++ b/src/style/sprite.cpp @@ -83,6 +83,8 @@ void Sprite::parseJSON(std::shared_ptr &sprite) { sprite->body.clear(); if (d.IsObject()) { + std::unordered_map pos; + for (rapidjson::Value::ConstMemberIterator itr = d.MemberBegin(); itr != d.MemberEnd(); ++itr) { const std::string& name = itr->name.GetString(); const rapidjson::Value& value = itr->value; @@ -99,9 +101,11 @@ void Sprite::parseJSON(std::shared_ptr &sprite) { if (value.HasMember("width")) width = value["width"].GetInt(); if (value.HasMember("height")) height = value["height"].GetInt(); if (value.HasMember("pixelRatio")) pixelRatio = value["pixelRatio"].GetInt(); - sprite->pos.emplace(name, SpritePosition { x, y, width, height, pixelRatio }); + pos.emplace(name, SpritePosition { x, y, width, height, pixelRatio }); } } + + sprite->pos.swap(pos); } }