From 92cd19a5961d6de45dd3ea1c8f7c2b4be108cbae Mon Sep 17 00:00:00 2001 From: Alissa Bonas Date: Mon, 16 Dec 2013 16:41:28 +0200 Subject: [PATCH 1/1] 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 --- .../controller/switchmanager/internal/SwitchManager.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) 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; -- 2.36.6