Code simplification: Don't store the same information in two places
@@ -150,22 +150,19 @@ class PhaseOptimizer implements CompilerPass {
*/
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);
}
}
@@ -536,6 +533,10 @@ class PhaseOptimizer implements CompilerPass {
myPasses.addAll(optimalPasses);
}
+ boolean isPopulated() {
+ return !myPasses.isEmpty();
+ }
+
private boolean isCodeRemovalLoop() {
for (NamedPass pass : this.myPasses) {
if (CODE_REMOVING_PASSES.contains(pass.name)) {
