Special case the single name case in SyntaticScopeCreator#declareLHS to avoid the overhead of dealing with destructuring in the most common case.
@@ -164,10 +164,16 @@ public final class SyntacticScopeCreator implements ScopeCreator {
}
private void declareLHS(Scope s, Node n) {
+ if (n.hasOneChild() && n.getFirstChild().isName()) {
+ // NAME is most common and trivial case. This code is hot so it is worth special casing.
+ // to avoid extra GC and cpu cycles.
+ declareVar(s, n.getFirstChild());
+ } else {
for (Node lhs : NodeUtil.findLhsNodesInNode(n)) {
declareVar(s, lhs);
}
}
+ }
/**
* Scans and gather variables declarations under a Node
