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/ir/SkSLIndexExpression.h b/src/sksl/ir/SkSLIndexExpression.h
index 538c656..f5b0d09 100644
--- a/src/sksl/ir/SkSLIndexExpression.h
+++ b/src/sksl/ir/SkSLIndexExpression.h
@@ -16,21 +16,21 @@
 /**
  * Given a type, returns the type that will result from extracting an array value from it.
  */
-static std::shared_ptr<Type> index_type(const Type& type) {
+static const Type& index_type(const Context& context, const Type& type) {
     if (type.kind() == Type::kMatrix_Kind) {
-        if (type.componentType() == kFloat_Type) {
+        if (type.componentType() == *context.fFloat_Type) {
             switch (type.columns()) {
-                case 2: return kVec2_Type;
-                case 3: return kVec3_Type;
-                case 4: return kVec4_Type;
+                case 2: return *context.fVec2_Type;
+                case 3: return *context.fVec3_Type;
+                case 4: return *context.fVec4_Type;
                 default: ASSERT(false);
             }
         } else {
-            ASSERT(type.componentType() == kDouble_Type);
+            ASSERT(type.componentType() == *context.fDouble_Type);
             switch (type.columns()) {
-                case 2: return kDVec2_Type;
-                case 3: return kDVec3_Type;
-                case 4: return kDVec4_Type;
+                case 2: return *context.fDVec2_Type;
+                case 3: return *context.fDVec3_Type;
+                case 4: return *context.fDVec4_Type;
                 default: ASSERT(false);
             }
         }
@@ -42,11 +42,12 @@
  * An expression which extracts a value from an array or matrix, as in 'm[2]'.
  */
 struct IndexExpression : public Expression {
-    IndexExpression(std::unique_ptr<Expression> base, std::unique_ptr<Expression> index)
-    : INHERITED(base->fPosition, kIndex_Kind, index_type(*base->fType))
+    IndexExpression(const Context& context, std::unique_ptr<Expression> base, 
+                    std::unique_ptr<Expression> index)
+    : INHERITED(base->fPosition, kIndex_Kind, index_type(context, base->fType))
     , fBase(std::move(base))
     , fIndex(std::move(index)) {
-        ASSERT(fIndex->fType == kInt_Type);
+        ASSERT(fIndex->fType == *context.fInt_Type);
     }
 
     std::string description() const override {