Skip to content

Commit a381b20

Browse files
rishipalcopybara-github
authored andcommitted
Skip one unnecessary global traversal of source and externs in the let/const rewriting pass.
Since the let/const rewriting pass now runs post-normalize, it need not run the MakeDeclaredNamesUnique renamer across the entire source and externs. This saves the cost of 1 full traversal on the unoptimized source+externs AST. PiperOrigin-RevId: 621147152
1 parent b45f82e commit a381b20

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/com/google/javascript/jscomp/Es6RewriteBlockScopedDeclaration.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,8 @@ public void visit(NodeTraversal t, Node n, Node parent) {
8686

8787
@Override
8888
public void process(Node externs, Node root) {
89-
// Make all declared names unique, so we can safely just switch 'let' or 'const' to 'var' in all
90-
// non-loop cases.
91-
MakeDeclaredNamesUnique renamer = MakeDeclaredNamesUnique.builder().build();
92-
NodeTraversal.traverseRoots(compiler, renamer, externs, root);
89+
// All declared names are already unique post normalize, so we can safely just switch 'let' or
90+
// 'const' to 'var' in all non-loop cases.
9391
// - Gather a list of let & const variables
9492
// - Also add `= void 0` to any that are not initialized.
9593
NodeTraversal.traverse(compiler, root, this);

0 commit comments

Comments
 (0)