Committed by
Gerrit Code Review
Keep using same iterator.
Change-Id: Icfdb9d79c188677dd89c851644ceb855e3bb9781
Showing
1 changed file
with
4 additions
and
3 deletions
| ... | @@ -154,14 +154,15 @@ public abstract class ConnectivityIntentCompiler<T extends ConnectivityIntent> | ... | @@ -154,14 +154,15 @@ public abstract class ConnectivityIntentCompiler<T extends ConnectivityIntent> |
| 154 | 154 | ||
| 155 | @Override | 155 | @Override |
| 156 | public double weight(TopologyEdge edge) { | 156 | public double weight(TopologyEdge edge) { |
| 157 | - if (!constraints.iterator().hasNext()) { | ||
| 158 | - return 1.0; | ||
| 159 | - } | ||
| 160 | 157 | ||
| 161 | // iterate over all constraints in order and return the weight of | 158 | // iterate over all constraints in order and return the weight of |
| 162 | // the first one with fast fail over the first failure | 159 | // the first one with fast fail over the first failure |
| 163 | Iterator<Constraint> it = constraints.iterator(); | 160 | Iterator<Constraint> it = constraints.iterator(); |
| 164 | 161 | ||
| 162 | + if (!it.hasNext()) { | ||
| 163 | + return 1.0; | ||
| 164 | + } | ||
| 165 | + | ||
| 165 | double cost = it.next().cost(edge.link(), resourceService::isAvailable); | 166 | double cost = it.next().cost(edge.link(), resourceService::isAvailable); |
| 166 | while (it.hasNext() && cost > 0) { | 167 | while (it.hasNext() && cost > 0) { |
| 167 | if (it.next().cost(edge.link(), resourceService::isAvailable) < 0) { | 168 | if (it.next().cost(edge.link(), resourceService::isAvailable) < 0) { | ... | ... |
-
Please register or login to post a comment