SkSL performance improvements (plus a couple of minor warning fixes)
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2131223002

Committed: https://skia.googlesource.com/skia/+/9fd67a1f53809f5eff1210dd107241b450c48acc
Review-Url: https://codereview.chromium.org/2131223002
diff --git a/src/sksl/SkSLParser.cpp b/src/sksl/SkSLParser.cpp
index fa302af..edff0c6 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 @@
             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 @@
     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));
 }