Use an unordered map for intrinsics in the IR generator.
Several small tweaks:
- Replace std::pair<> with a struct (IRIntrinsic) so we can use names
(fIntrinsic/fAlreadyIncluded) instead of .first and .second.
- Replace std::map<String, std::pair<...>> with a name (IRIntrinsicMap).
- Replace map with unordered_map, since we don't rely on order anywhere.
Change-Id: I508eb3cde5bd4fddcc0b3d02d6ce21d33f9a5421
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/313523
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/sksl/SkSLIRGenerator.cpp b/src/sksl/SkSLIRGenerator.cpp
index ad5fbaa..3a83cbd 100644
--- a/src/sksl/SkSLIRGenerator.cpp
+++ b/src/sksl/SkSLIRGenerator.cpp
@@ -192,7 +192,7 @@
}
SkASSERT(fIntrinsics);
for (auto& pair : *fIntrinsics) {
- pair.second.second = false;
+ pair.second.fAlreadyIncluded = false;
}
}
@@ -2398,9 +2398,9 @@
void IRGenerator::copyIntrinsicIfNeeded(const FunctionDeclaration& function) {
auto found = fIntrinsics->find(function.description());
- if (found != fIntrinsics->end() && !found->second.second) {
- found->second.second = true;
- FunctionDefinition& original = found->second.first->as<FunctionDefinition>();
+ if (found != fIntrinsics->end() && !found->second.fAlreadyIncluded) {
+ found->second.fAlreadyIncluded = true;
+ FunctionDefinition& original = found->second.fIntrinsic->as<FunctionDefinition>();
for (const FunctionDeclaration* f : original.fReferencedIntrinsics) {
this->copyIntrinsicIfNeeded(*f);
}
@@ -3061,9 +3061,9 @@
if (!result) {
auto found = fIntrinsics->find(type.fName);
if (found != fIntrinsics->end()) {
- SkASSERT(!found->second.second);
- found->second.second = true;
- fProgramElements->push_back(found->second.first->clone());
+ SkASSERT(!found->second.fAlreadyIncluded);
+ found->second.fAlreadyIncluded = true;
+ fProgramElements->push_back(found->second.fIntrinsic->clone());
return this->convertTypeField(offset, type, field);
}
fErrors.error(offset, "type '" + type.fName + "' does not have a field named '" + field +