From: Alessandro Boch Date: Mon, 16 Dec 2013 20:07:09 +0000 (+0000) Subject: Merge "Improve iteration over subnets map by using entrySet instead of keyset. It... X-Git-Tag: jenkins-controller-bulk-release-prepare-only-2-1~184 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=523c3f0629438462c5bb7be4adcaf7103a3f7ea6;hp=5fe4a2c1eb78c0d0fe349354f39df4861ded6ee3 Merge "Improve iteration over subnets map by using entrySet instead of keyset. It is more efficient to iterate on the entrySet because it avoids the Map.get(key) lookup." --- diff --git a/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManager.java b/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManager.java index 41c783618d..f895ca0c85 100644 --- a/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManager.java +++ b/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManager.java @@ -691,12 +691,9 @@ public class SwitchManager implements ISwitchManager, IConfigurationContainerAwa return DEFAULT_SUBNET; } - Subnet sub; - Set indices = subnets.keySet(); - for (InetAddress i : indices) { - sub = subnets.get(i); - if (sub.isSubnetOf(networkAddress)) { - return sub; + for(Map.Entry subnetEntry : subnets.entrySet()) { + if(subnetEntry.getValue().isSubnetOf(networkAddress)) { + return subnetEntry.getValue(); } } return null;