Convert expression arrays from std::vector to SkSTArray.
This will help us avoid allocations for simple expressions.
Nanobench shows ~5% improvement with an array size of 2:
http://screen/8oDEY7hjrhY8C6k
Other array sizes will show different levels of improvement, but I
haven't done an exhaustive trial. (2 was noticeably better than 1.)
Change-Id: I005a7896a0db83df4e3c2d3c0fa3321203f8a0b3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/325861
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
diff --git a/src/sksl/SkSLMetalCodeGenerator.cpp b/src/sksl/SkSLMetalCodeGenerator.cpp
index 8abe2b9..beead42 100644
--- a/src/sksl/SkSLMetalCodeGenerator.cpp
+++ b/src/sksl/SkSLMetalCodeGenerator.cpp
@@ -213,7 +213,7 @@
void MetalCodeGenerator::writeFunctionCall(const FunctionCall& c) {
const FunctionDeclaration& function = c.function();
- const std::vector<std::unique_ptr<Expression>>& arguments = c.arguments();
+ const ExpressionArray& arguments = c.arguments();
const auto& entry = fIntrinsicMap.find(function.name());
if (entry != fIntrinsicMap.end()) {
this->writeIntrinsicCall(c);
@@ -357,7 +357,7 @@
}
void MetalCodeGenerator::writeSpecialIntrinsic(const FunctionCall & c, SpecialIntrinsic kind) {
- const std::vector<std::unique_ptr<Expression>>& arguments = c.arguments();
+ const ExpressionArray& arguments = c.arguments();
switch (kind) {
case kTexture_SpecialIntrinsic: {
this->writeExpression(*arguments[0], kSequence_Precedence);
@@ -438,8 +438,8 @@
// Assembles a matrix of type floatRxC by concatenating an arbitrary mix of values, named `x0`,
// `x1`, etc. An error is written if the expression list don't contain exactly R*C scalars.
-void MetalCodeGenerator::assembleMatrixFromExpressions(
- const std::vector<std::unique_ptr<Expression>>& args, int rows, int columns) {
+void MetalCodeGenerator::assembleMatrixFromExpressions(const ExpressionArray& args,
+ int rows, int columns) {
size_t argIndex = 0;
int argPosition = 0;
@@ -505,7 +505,7 @@
const Type& matrix = c.type();
int columns = matrix.columns();
int rows = matrix.rows();
- const std::vector<std::unique_ptr<Expression>>& args = c.arguments();
+ const ExpressionArray& args = c.arguments();
// Create the helper-method name and use it as our lookup key.
String name;