Avoid waste in registerNewlyDiscovered... when there aren't any
RELNOTES: None.
@@ -40,6 +40,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -629,8 +630,13 @@ public final class ParallelEvaluator implements Evaluator {
Set<SkyKey> oldDeps,
SkyFunctionEnvironment env)
throws InterruptedException {
+ Iterator<SkyKey> it = env.getNewlyRequestedDeps().iterator();
+ if (!it.hasNext()) {
+ return;
+ }
Set<SkyKey> unfinishedDeps = new HashSet<>();
- for (SkyKey dep : env.getNewlyRequestedDeps()) {
+ while (it.hasNext()) {
+ SkyKey dep = it.next();
if (!isDoneForBuild(newlyRequestedDepMap.get(dep))) {
unfinishedDeps.add(dep);
}
