Use SkTHashMap for the intrinsic-name map.

This leverages our new ability to initialize a hash map at construction
time (http://review.skia.org/515319)

Change-Id: I2e6038b3a6645f19128930d3c58707a682b5232f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/515320
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
This commit is contained in:
John Stiles 2022-03-03 17:01:59 -05:00 committed by SkCQ
parent 6105180115
commit b3deb0a652

View File

@ -15,7 +15,7 @@ namespace SkSL {
static IntrinsicKind identify_intrinsic(std::string_view functionName) {
#define SKSL_INTRINSIC(name) {#name, k_##name##_IntrinsicKind},
static const auto* kAllIntrinsics = new std::unordered_map<std::string_view, IntrinsicKind>{
static const auto* kAllIntrinsics = new SkTHashMap<std::string_view, IntrinsicKind>{
SKSL_INTRINSIC_LIST
};
#undef SKSL_INTRINSIC
@ -24,12 +24,8 @@ static IntrinsicKind identify_intrinsic(std::string_view functionName) {
functionName.remove_prefix(1);
}
auto iter = kAllIntrinsics->find(functionName);
if (iter != kAllIntrinsics->end()) {
return iter->second;
}
return kNotIntrinsic;
IntrinsicKind* kind = kAllIntrinsics->find(functionName);
return kind ? *kind : kNotIntrinsic;
}
static bool check_modifiers(const Context& context,