From: Alissa Bonas Date: Mon, 16 Dec 2013 14:41:28 +0000 (+0200) Subject: Improve iteration over subnets map by using entrySet instead of keyset. X-Git-Tag: jenkins-controller-bulk-release-prepare-only-2-1~184^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=92cd19a5961d6de45dd3ea1c8f7c2b4be108cbae 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. Change-Id: I8ec04ebfe5b22b67a488b81987f0d1f8bd1e107d Signed-off-by: Alissa Bonas --- 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;