Speed up program visitors in the Inliner.
They don't inspect Expressions at all, but by default, a ProgramVisitor
will completely traverse every Expression. This change improved local
runs of nanobench on sksl_large by ~7%.
Change-Id: I7604ffa220c6081c3cd39b5a22520fb41421fcba
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/385878
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
diff --git a/src/sksl/SkSLInliner.cpp b/src/sksl/SkSLInliner.cpp
index 5151abc..32f2df7 100644
--- a/src/sksl/SkSLInliner.cpp
+++ b/src/sksl/SkSLInliner.cpp
@@ -63,6 +63,11 @@
this->visitProgramElement(funcDef);
}
+ bool visitExpression(const Expression& expr) override {
+ // Do not recurse into expressions.
+ return false;
+ }
+
bool visitStatement(const Statement& stmt) override {
switch (stmt.kind()) {
case Statement::Kind::kBlock: {
@@ -100,6 +105,11 @@
this->visitProgramElement(funcDef);
}
+ bool visitExpression(const Expression& expr) override {
+ // Do not recurse into expressions.
+ return false;
+ }
+
bool visitStatement(const Statement& stmt) override {
switch (stmt.kind()) {
case Statement::Kind::kDo:
@@ -192,6 +202,11 @@
this->visitProgramElement(funcDef);
}
+ bool visitExpression(const Expression& expr) override {
+ // Do not recurse into expressions.
+ return false;
+ }
+
bool visitStatement(const Statement& stmt) override {
switch (stmt.kind()) {
case Statement::Kind::kReturn: {