Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Optimization - calculate the subnet prefix only once.
[controller.git]
/
opendaylight
/
switchmanager
/
api
/
src
/
main
/
java
/
org
/
opendaylight
/
controller
/
switchmanager
/
Subnet.java
diff --git
a/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Subnet.java
b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Subnet.java
index 56df8e26bd094b82bdd8d6ddb89cec4ab249e7a9..2794109c242bc420677b1e6209bc72921a8a7f6d 100644
(file)
--- a/
opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Subnet.java
+++ b/
opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Subnet.java
@@
-25,6
+25,7
@@
public class Subnet implements Cloneable, Serializable {
private static final long serialVersionUID = 1L;
// Key fields
private InetAddress networkAddress;
private static final long serialVersionUID = 1L;
// Key fields
private InetAddress networkAddress;
+ private transient InetAddress subnetPrefix;
private short subnetMaskLength;
// Property fields
private short vlan;
private short subnetMaskLength;
// Property fields
private short vlan;
@@
-114,6
+115,7
@@
public class Subnet implements Cloneable, Serializable {
*/
public Subnet setNetworkAddress(InetAddress networkAddress) {
this.networkAddress = networkAddress;
*/
public Subnet setNetworkAddress(InetAddress networkAddress) {
this.networkAddress = networkAddress;
+ this.subnetPrefix = null;
return this;
}
return this;
}
@@
-159,10
+161,12
@@
public class Subnet implements Cloneable, Serializable {
if (ip == null) {
return false;
}
if (ip == null) {
return false;
}
- InetAddress thisPrefix = getPrefixForAddress(this.networkAddress);
+ if(subnetPrefix == null) {
+ subnetPrefix = getPrefixForAddress(this.networkAddress);
+ }
InetAddress otherPrefix = getPrefixForAddress(ip);
boolean isSubnetOf = true;
InetAddress otherPrefix = getPrefixForAddress(ip);
boolean isSubnetOf = true;
- if (((
thisPrefix == null) || (otherPrefix == null)) || (!this
Prefix.equals(otherPrefix)) ) {
+ if (((
subnetPrefix == null) || (otherPrefix == null)) || (!subnet
Prefix.equals(otherPrefix)) ) {
isSubnetOf = false;
}
return isSubnetOf;
isSubnetOf = false;
}
return isSubnetOf;