Use SkTHashMap for parser layout tokens.
It seems to reduce code size by about 1K every time we remove an unordered map. Change-Id: I120aa6130b4283c7d41b9db5bfeec3c2eb99bcd4 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/515545 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: John Stiles <johnstiles@google.com> Auto-Submit: John Stiles <johnstiles@google.com>
This commit is contained in:
parent
3bf76ab829
commit
227af34e24
@ -78,11 +78,11 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
std::unordered_map<std::string_view, DSLParser::LayoutToken>* DSLParser::layoutTokens;
|
||||
SkTHashMap<std::string_view, DSLParser::LayoutToken>* DSLParser::sLayoutTokens;
|
||||
|
||||
void DSLParser::InitLayoutMap() {
|
||||
layoutTokens = new std::unordered_map<std::string_view, LayoutToken>;
|
||||
#define TOKEN(name, text) (*layoutTokens)[text] = LayoutToken::name
|
||||
sLayoutTokens = new SkTHashMap<std::string_view, LayoutToken>;
|
||||
#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;
|
||||
|
@ -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 <memory>
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace SkSL {
|
||||
|
||||
@ -325,7 +325,7 @@ private:
|
||||
bool fOldEncounteredFatalError;
|
||||
};
|
||||
|
||||
static std::unordered_map<std::string_view, LayoutToken>* layoutTokens;
|
||||
static SkTHashMap<std::string_view, LayoutToken>* sLayoutTokens;
|
||||
|
||||
Compiler& fCompiler;
|
||||
ProgramSettings fSettings;
|
||||
|
Loading…
Reference in New Issue
Block a user