Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(971)

Unified Diff: src/sksl/SkSLParser.cpp

Issue 2131223002: SkSL performance improvements (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/sksl/SkSLIRGenerator.cpp ('k') | src/sksl/SkSLSPIRVCodeGenerator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/sksl/SkSLParser.cpp
diff --git a/src/sksl/SkSLParser.cpp b/src/sksl/SkSLParser.cpp
index fa302af0d3debf78f31d2ee0db0fd4912fb616f4..edff0c67d15516a9f4b4f8def23c9bdced04ea36 100644
--- a/src/sksl/SkSLParser.cpp
+++ b/src/sksl/SkSLParser.cpp
@@ -52,6 +52,7 @@
#include "ast/SkSLASTVarDeclarationStatement.h"
#include "ast/SkSLASTWhileStatement.h"
#include "ir/SkSLSymbolTable.h"
+#include "ir/SkSLType.h"
namespace SkSL {
@@ -290,17 +291,17 @@ std::unique_ptr<ASTType> Parser::structDeclaration() {
return nullptr;
}
for (size_t i = 0; i < decl->fNames.size(); i++) {
- auto type = std::static_pointer_cast<Type>(fTypes[decl->fType->fName]);
+ auto type = (const Type*) fTypes[decl->fType->fName];
for (int j = (int) decl->fSizes[i].size() - 1; j >= 0; j--) {
- if (decl->fSizes[i][j]->fKind == ASTExpression::kInt_Kind) {
+ if (decl->fSizes[i][j]->fKind != ASTExpression::kInt_Kind) {
this->error(decl->fPosition, "array size in struct field must be a constant");
}
uint64_t columns = ((ASTIntLiteral&) *decl->fSizes[i][j]).fValue;
std::string name = type->name() + "[" + to_string(columns) + "]";
- type = std::shared_ptr<Type>(new Type(name, Type::kArray_Kind, std::move(type),
- (int) columns));
+ type = new Type(name, Type::kArray_Kind, *type, (int) columns);
+ fTypes.takeOwnership((Type*) type);
}
- fields.push_back(Type::Field(decl->fModifiers, decl->fNames[i], std::move(type)));
+ fields.push_back(Type::Field(decl->fModifiers, decl->fNames[i], *type));
if (decl->fValues[i]) {
this->error(decl->fPosition, "initializers are not permitted on struct fields");
}
@@ -309,9 +310,8 @@ std::unique_ptr<ASTType> Parser::structDeclaration() {
if (!this->expect(Token::RBRACE, "'}'")) {
return nullptr;
}
- std::shared_ptr<Type> type(new Type(name.fText, fields));
- fTypes.add(type->fName, type);
- return std::unique_ptr<ASTType>(new ASTType(name.fPosition, type->fName,
+ fTypes.add(name.fText, std::unique_ptr<Type>(new Type(name.fText, fields)));
+ return std::unique_ptr<ASTType>(new ASTType(name.fPosition, name.fText,
ASTType::kStruct_Kind));
}
« no previous file with comments | « src/sksl/SkSLIRGenerator.cpp ('k') | src/sksl/SkSLSPIRVCodeGenerator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698