Convert statement arrays from std::vector to SkSTArray.

This will help us avoid allocations for arrays of statements.

Currently, this is a wash in Nanobench (~0% change). In the near
future, we expect to collapse the expression array and statement array
into a single hybrid array, and this helps bring us closer to that end
goal.

Change-Id: Id146907352799c41b568090ab65e454247b294c8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/325625
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/src/sksl/SkSLInliner.cpp b/src/sksl/SkSLInliner.cpp
index da97b1c..36762f9 100644
--- a/src/sksl/SkSLInliner.cpp
+++ b/src/sksl/SkSLInliner.cpp
@@ -443,14 +443,16 @@
         return nullptr;
     };
     auto blockStmts = [&](const Block& block) {
-        std::vector<std::unique_ptr<Statement>> result;
+        StatementArray result;
+        result.reserve(block.children().size());
         for (const std::unique_ptr<Statement>& child : block.children()) {
             result.push_back(stmt(child));
         }
         return result;
     };
-    auto stmts = [&](const std::vector<std::unique_ptr<Statement>>& ss) {
-        std::vector<std::unique_ptr<Statement>> result;
+    auto stmts = [&](const StatementArray& ss) {
+        StatementArray result;
+        result.reserve(ss.size());
         for (const auto& s : ss) {
             result.push_back(stmt(s));
         }
@@ -510,9 +512,10 @@
                                 expr(r.expression()),
                                 &resultExpr->type()));
                 if (haveEarlyReturns) {
-                    std::vector<std::unique_ptr<Statement>> block;
+                    StatementArray block;
+                    block.reserve(2);
                     block.push_back(std::move(assignment));
-                    block.emplace_back(new BreakStatement(offset));
+                    block.push_back(std::make_unique<BreakStatement>(offset));
                     return std::make_unique<Block>(offset, std::move(block), /*symbols=*/nullptr,
                                                    /*isScope=*/true);
                 } else {
@@ -529,9 +532,10 @@
         case Statement::Kind::kSwitch: {
             const SwitchStatement& ss = statement.as<SwitchStatement>();
             std::vector<std::unique_ptr<SwitchCase>> cases;
+            cases.reserve(ss.fCases.size());
             for (const auto& sc : ss.fCases) {
-                cases.emplace_back(new SwitchCase(offset, expr(sc->fValue),
-                                                  stmts(sc->fStatements)));
+                cases.push_back(std::make_unique<SwitchCase>(offset, expr(sc->fValue),
+                                                             stmts(sc->fStatements)));
             }
             return std::make_unique<SwitchStatement>(offset, ss.fIsStatic, expr(ss.fValue),
                                                      std::move(cases), ss.fSymbols);
@@ -539,6 +543,7 @@
         case Statement::Kind::kVarDeclaration: {
             const VarDeclaration& decl = statement.as<VarDeclaration>();
             std::vector<std::unique_ptr<Expression>> sizes;
+            sizes.reserve(decl.fSizes.size());
             for (const auto& size : decl.fSizes) {
                 sizes.push_back(expr(size));
             }
@@ -597,8 +602,7 @@
     const bool hasEarlyReturn = has_early_return(function);
 
     InlinedCall inlinedCall;
-    inlinedCall.fInlinedBody = std::make_unique<Block>(offset,
-                                                       std::vector<std::unique_ptr<Statement>>{},
+    inlinedCall.fInlinedBody = std::make_unique<Block>(offset, StatementArray{},
                                                        /*symbols=*/nullptr,
                                                        /*isScope=*/false);
 
@@ -692,7 +696,7 @@
     }
 
     const Block& body = function.fBody->as<Block>();
-    auto inlineBlock = std::make_unique<Block>(offset, std::vector<std::unique_ptr<Statement>>{});
+    auto inlineBlock = std::make_unique<Block>(offset, StatementArray{});
     inlineBlock->children().reserve(body.children().size());
     for (const std::unique_ptr<Statement>& stmt : body.children()) {
         inlineBlock->children().push_back(this->inlineStatement(offset, &varMap, symbolTableForCall,