Skip to content

Commit

Permalink
Replace 'for(int i)' loop with 'for each' for better performance.
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=242520832
  • Loading branch information
DylanDavidson authored and brad4d committed Apr 9, 2019
1 parent 958ad5f commit d1749c1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/com/google/javascript/jscomp/NodeTraversal.java
Original file line number Diff line number Diff line change
Expand Up @@ -1054,8 +1054,9 @@ private void popScope(boolean quietly) {
public AbstractScope<?, ?> getAbstractScope() {
AbstractScope<?, ?> scope = scopes.peek();

for (int i = 0; i < scopeRoots.size(); i++) {
scope = scopeCreator.createScope(scopeRoots.get(i), scope);
// NOTE(dylandavidson): Use for-each loop to avoid slow ArrayList#get performance.
for (Node scopeRoot : scopeRoots) {
scope = scopeCreator.createScope(scopeRoot, scope);
scopes.push(scope);
}
scopeRoots.clear();
Expand Down

0 comments on commit d1749c1

Please sign in to comment.