diff --git a/src/sksl/SkSLDSLParser.cpp b/src/sksl/SkSLDSLParser.cpp index 8c44c8493d..9a5f4c1e27 100644 --- a/src/sksl/SkSLDSLParser.cpp +++ b/src/sksl/SkSLDSLParser.cpp @@ -78,11 +78,11 @@ public: } }; -std::unordered_map* DSLParser::layoutTokens; +SkTHashMap* DSLParser::sLayoutTokens; void DSLParser::InitLayoutMap() { - layoutTokens = new std::unordered_map; - #define TOKEN(name, text) (*layoutTokens)[text] = LayoutToken::name + sLayoutTokens = new SkTHashMap; + #define TOKEN(name, text) sLayoutTokens->set(text, LayoutToken::name) TOKEN(LOCATION, "location"); TOKEN(OFFSET, "offset"); TOKEN(BINDING, "binding"); @@ -757,9 +757,9 @@ DSLLayout DSLParser::layout() { for (;;) { Token t = this->nextToken(); std::string text(this->text(t)); - auto found = layoutTokens->find(text); - if (found != layoutTokens->end()) { - switch (found->second) { + LayoutToken* found = sLayoutTokens->find(text); + if (found != nullptr) { + switch (*found) { case LayoutToken::ORIGIN_UPPER_LEFT: result.originUpperLeft(this->position(t)); break; diff --git a/src/sksl/SkSLDSLParser.h b/src/sksl/SkSLDSLParser.h index f8af04c438..3765ff576c 100644 --- a/src/sksl/SkSLDSLParser.h +++ b/src/sksl/SkSLDSLParser.h @@ -9,6 +9,7 @@ #define SKSL_DSLPARSER #include "include/private/SkSLProgramKind.h" +#include "include/private/SkTHash.h" #include "include/sksl/DSL.h" #include "include/sksl/DSLSymbols.h" #include "src/sksl/SkSLLexer.h" @@ -17,7 +18,6 @@ #include #include #include -#include namespace SkSL { @@ -325,7 +325,7 @@ private: bool fOldEncounteredFatalError; }; - static std::unordered_map* layoutTokens; + static SkTHashMap* sLayoutTokens; Compiler& fCompiler; ProgramSettings fSettings;