From 76e6ea5ab6d8c99be447c1f73416c90f37299c6f Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 1 Nov 2019 14:57:03 +0100 Subject: [PATCH] Eliminate NeutronvpnUtils.isNetworkOfType() This method is used from only a single caller, which is checking the same augmentation. Inline the check into the caller, making sure we look up the augmentation only once -- thus speeding up the NetworkTypeFlat case. Change-Id: Ia3e767b8582af6ee61ed84ed13d0d8627a0eaa69 Signed-off-by: Robert Varga --- .../netvirt/neutronvpn/NeutronvpnUtils.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/neutronvpn/impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronvpnUtils.java b/neutronvpn/impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronvpnUtils.java index 9a19f971b7..626d0614ec 100644 --- a/neutronvpn/impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronvpnUtils.java +++ b/neutronvpn/impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronvpnUtils.java @@ -1103,19 +1103,20 @@ public class NeutronvpnUtils { return npe != null && SUPPORTED_NETWORK_TYPES.contains(npe.getNetworkType()); } - static boolean isNetworkOfType(Network network, Class type) { - NetworkProviderExtension npe = network.augmentation(NetworkProviderExtension.class); - if (npe != null && npe.getNetworkType() != null) { - return type.isAssignableFrom(npe.getNetworkType()); + static boolean isFlatOrVlanNetwork(Network network) { + if (network != null) { + NetworkProviderExtension npe = network.augmentation(NetworkProviderExtension.class); + if (npe != null) { + Class npeType = npe.getNetworkType(); + if (npeType != null) { + return NetworkTypeVlan.class.isAssignableFrom(npeType) + || NetworkTypeFlat.class.isAssignableFrom(npeType); + } + } } return false; } - static boolean isFlatOrVlanNetwork(Network network) { - return network != null - && (isNetworkOfType(network, NetworkTypeVlan.class) || isNetworkOfType(network, NetworkTypeFlat.class)); - } - static boolean isVlanOrVxlanNetwork(Class type) { return type.isAssignableFrom(NetworkTypeVxlan.class) || type.isAssignableFrom(NetworkTypeVlan.class); } -- 2.36.6