Yuta HIGUCHI
Committed by Gerrit Code Review

Keep using same iterator.

Change-Id: Icfdb9d79c188677dd89c851644ceb855e3bb9781
......@@ -154,14 +154,15 @@ public abstract class ConnectivityIntentCompiler<T extends ConnectivityIntent>
@Override
public double weight(TopologyEdge edge) {
if (!constraints.iterator().hasNext()) {
return 1.0;
}
// iterate over all constraints in order and return the weight of
// the first one with fast fail over the first failure
Iterator<Constraint> it = constraints.iterator();
if (!it.hasNext()) {
return 1.0;
}
double cost = it.next().cost(edge.link(), resourceService::isAvailable);
while (it.hasNext() && cost > 0) {
if (it.next().cost(edge.link(), resourceService::isAvailable) < 0) {
......