Skip to content

Commit

Permalink
Code simplification: Don't store the same information in two places
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179108920
  • Loading branch information
tbreisacher authored and brad4d committed Dec 15, 2017
1 parent 7549737 commit 110b3b7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/com/google/javascript/jscomp/PhaseOptimizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,22 +150,19 @@ PhaseOptimizer withProgress(ProgressRange range) {
*/
void consume(List<PassFactory> factories) {
Loop currentLoop = new Loop();
boolean isCurrentLoopPopulated = false;
for (PassFactory factory : factories) {
if (factory.isOneTimePass()) {
if (isCurrentLoopPopulated) {
if (currentLoop.isPopulated()) {
passes.add(currentLoop);
currentLoop = new Loop();
isCurrentLoopPopulated = false;
}
addOneTimePass(factory);
} else {
currentLoop.addLoopedPass(factory);
isCurrentLoopPopulated = true;
}
}

if (isCurrentLoopPopulated) {
if (currentLoop.isPopulated()) {
passes.add(currentLoop);
}
}
Expand Down Expand Up @@ -536,6 +533,10 @@ private void optimizePasses() {
myPasses.addAll(optimalPasses);
}

boolean isPopulated() {
return !myPasses.isEmpty();
}

private boolean isCodeRemovalLoop() {
for (NamedPass pass : this.myPasses) {
if (CODE_REMOVING_PASSES.contains(pass.name)) {
Expand Down

0 comments on commit 110b3b7

Please sign in to comment.