Converted InterfaceBlock name to string_view
Change-Id: I1d64165b43bc956d0f965fe55f29eebb37a8dbd6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/433002
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/sksl/SkSLIRGenerator.cpp b/src/sksl/SkSLIRGenerator.cpp
index 093e3dd..f47555d 100644
--- a/src/sksl/SkSLIRGenerator.cpp
+++ b/src/sksl/SkSLIRGenerator.cpp
@@ -1078,8 +1078,8 @@
}
return std::make_unique<SkSL::InterfaceBlock>(intf.fOffset,
var,
- String(id.fTypeName),
- String(id.fInstanceName),
+ id.fTypeName,
+ id.fInstanceName,
arraySize,
symbols);
}
diff --git a/src/sksl/SkSLRehydrator.cpp b/src/sksl/SkSLRehydrator.cpp
index c4679ef..37219d8 100644
--- a/src/sksl/SkSLRehydrator.cpp
+++ b/src/sksl/SkSLRehydrator.cpp
@@ -299,12 +299,11 @@
case Rehydrator::kInterfaceBlock_Command: {
const Symbol* var = this->symbol();
SkASSERT(var && var->is<Variable>());
- String typeName(this->readString());
- String instanceName(this->readString());
+ skstd::string_view typeName = this->readString();
+ skstd::string_view instanceName = this->readString();
int arraySize = this->readS8();
- return std::make_unique<InterfaceBlock>(/*offset=*/-1, &var->as<Variable>(),
- std::move(typeName), std::move(instanceName),
- arraySize, nullptr);
+ return std::make_unique<InterfaceBlock>(/*offset=*/-1, &var->as<Variable>(), typeName,
+ instanceName, arraySize, nullptr);
}
case Rehydrator::kVarDeclarations_Command: {
std::unique_ptr<Statement> decl = this->statement();
diff --git a/src/sksl/codegen/SkSLMetalCodeGenerator.cpp b/src/sksl/codegen/SkSLMetalCodeGenerator.cpp
index cc07b7b..ce4e93f 100644
--- a/src/sksl/codegen/SkSLMetalCodeGenerator.cpp
+++ b/src/sksl/codegen/SkSLMetalCodeGenerator.cpp
@@ -1847,7 +1847,8 @@
}
fInterfaceBlockNameMap[&intf] = intf.instanceName();
} else {
- fInterfaceBlockNameMap[&intf] = "_anonInterface" + to_string(fAnonInterfaceCount++);
+ fInterfaceBlockNameMap[&intf] = *fProgram.fSymbols->takeOwnershipOfString("_anonInterface" +
+ to_string(fAnonInterfaceCount++));
}
this->writeLine(";");
}
diff --git a/src/sksl/codegen/SkSLMetalCodeGenerator.h b/src/sksl/codegen/SkSLMetalCodeGenerator.h
index b0a75a2..7fdd793 100644
--- a/src/sksl/codegen/SkSLMetalCodeGenerator.h
+++ b/src/sksl/codegen/SkSLMetalCodeGenerator.h
@@ -272,7 +272,7 @@
std::unordered_set<skstd::string_view> fReservedWords;
std::unordered_map<const Type::Field*, const InterfaceBlock*> fInterfaceBlockMap;
- std::unordered_map<const InterfaceBlock*, String> fInterfaceBlockNameMap;
+ std::unordered_map<const InterfaceBlock*, skstd::string_view> fInterfaceBlockNameMap;
int fAnonInterfaceCount = 0;
int fPaddingCount = 0;
const char* fLineEnding;
diff --git a/src/sksl/codegen/SkSLSPIRVCodeGenerator.cpp b/src/sksl/codegen/SkSLSPIRVCodeGenerator.cpp
index 6863c80..dfbf5d2 100644
--- a/src/sksl/codegen/SkSLSPIRVCodeGenerator.cpp
+++ b/src/sksl/codegen/SkSLSPIRVCodeGenerator.cpp
@@ -3648,7 +3648,7 @@
}
InterfaceBlock intf(/*offset=*/-1,
intfVar,
- String(name),
+ name,
/*instanceName=*/"",
/*arraySize=*/0,
std::make_shared<SymbolTable>(&fErrors, /*builtin=*/false));
diff --git a/src/sksl/dsl/DSLCore.cpp b/src/sksl/dsl/DSLCore.cpp
index 8fead3d..067e7c3 100644
--- a/src/sksl/dsl/DSLCore.cpp
+++ b/src/sksl/dsl/DSLCore.cpp
@@ -217,8 +217,7 @@
DSLWriter::MarkDeclared(var);
}
DSLWriter::ProgramElements().push_back(std::make_unique<SkSL::InterfaceBlock>(/*offset=*/-1,
- DSLWriter::Var(var), String(typeName), String(varName), arraySize,
- DSLWriter::SymbolTable()));
+ DSLWriter::Var(var), typeName, varName, arraySize, DSLWriter::SymbolTable()));
if (varName.empty()) {
const std::vector<SkSL::Type::Field>& fields = structType->fields();
const SkSL::Variable* skslVar = DSLWriter::Var(var);
diff --git a/src/sksl/ir/SkSLInterfaceBlock.h b/src/sksl/ir/SkSLInterfaceBlock.h
index 5d92433..b5ececd 100644
--- a/src/sksl/ir/SkSLInterfaceBlock.h
+++ b/src/sksl/ir/SkSLInterfaceBlock.h
@@ -10,6 +10,7 @@
#include <memory>
+#include "include/core/SkStringView.h"
#include "include/private/SkSLProgramElement.h"
#include "src/sksl/ir/SkSLSymbolTable.h"
#include "src/sksl/ir/SkSLVarDeclarations.h"
@@ -30,8 +31,9 @@
public:
static constexpr Kind kProgramElementKind = Kind::kInterfaceBlock;
- InterfaceBlock(int offset, const Variable* var, String typeName, String instanceName,
- int arraySize, std::shared_ptr<SymbolTable> typeOwner)
+ InterfaceBlock(int offset, const Variable* var, skstd::string_view typeName,
+ skstd::string_view instanceName, int arraySize,
+ std::shared_ptr<SymbolTable> typeOwner)
: INHERITED(offset, kProgramElementKind)
, fVariable(var)
, fTypeName(typeName)
@@ -47,11 +49,11 @@
fVariable = var;
}
- String typeName() const {
+ skstd::string_view typeName() const {
return fTypeName;
}
- String instanceName() const {
+ skstd::string_view instanceName() const {
return fInstanceName;
}
@@ -92,8 +94,8 @@
private:
const Variable* fVariable;
- String fTypeName;
- String fInstanceName;
+ skstd::string_view fTypeName;
+ skstd::string_view fInstanceName;
int fArraySize;
std::shared_ptr<SymbolTable> fTypeOwner;