Committed by
Gerrit Code Review
temporary fix for ONOS-1144: slow IPAddress.toString()
Change-Id: Ia7b9a71bb8c5b90dbc6256c35e8aa5a6567299c8
Showing
1 changed file
with
10 additions
and
0 deletions
... | @@ -331,6 +331,15 @@ public class IpAddress implements Comparable<IpAddress> { | ... | @@ -331,6 +331,15 @@ public class IpAddress implements Comparable<IpAddress> { |
331 | * @see java.lang.Object#toString() | 331 | * @see java.lang.Object#toString() |
332 | */ | 332 | */ |
333 | public String toString() { | 333 | public String toString() { |
334 | + // FIXME InetAddress is super slow | ||
335 | + switch (version) { | ||
336 | + case INET: | ||
337 | + return String.format("%d.%d.%d.%d", octets[0] & 0xff, | ||
338 | + octets[1] & 0xff, | ||
339 | + octets[2] & 0xff, | ||
340 | + octets[3] & 0xff); | ||
341 | + case INET6: | ||
342 | + default: | ||
334 | InetAddress inetAddr = null; | 343 | InetAddress inetAddr = null; |
335 | try { | 344 | try { |
336 | inetAddr = InetAddress.getByAddress(octets); | 345 | inetAddr = InetAddress.getByAddress(octets); |
... | @@ -341,6 +350,7 @@ public class IpAddress implements Comparable<IpAddress> { | ... | @@ -341,6 +350,7 @@ public class IpAddress implements Comparable<IpAddress> { |
341 | } | 350 | } |
342 | return InetAddresses.toAddrString(inetAddr); | 351 | return InetAddresses.toAddrString(inetAddr); |
343 | } | 352 | } |
353 | + } | ||
344 | 354 | ||
345 | /** | 355 | /** |
346 | * Gets the IP address name for the IP address version. | 356 | * Gets the IP address name for the IP address version. | ... | ... |
-
Please register or login to post a comment