Use Guava Splitter to split IP address
authorRobert Varga <[email protected]>
Fri, 12 Feb 2016 17:21:22 +0000 (18:21 +0100)
committerGerrit Code Review <[email protected]>
Wed, 2 Mar 2016 06:15:36 +0000 (06:15 +0000)
Using String.split() forces compilation of the regex, which is slow. Use
a thread-safe Splitter to perform the same job.

Change-Id: Icbc326a376bc9aaea692f80d01439e81a302bc5f
Signed-off-by: Robert Varga <[email protected]>
v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/VppIetfInterfaceListener.java

index 9b84a00..481c0ef 100644 (file)
@@ -16,6 +16,7 @@
 
 package io.fd.honeycomb.v3po.impl;
 
+import com.google.common.base.Splitter;
 import java.util.Collection;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
@@ -52,6 +53,7 @@ import org.slf4j.LoggerFactory;
 
 public class VppIetfInterfaceListener implements DataTreeChangeListener<Interface>, AutoCloseable {
     private static final Logger LOG = LoggerFactory.getLogger(VppIetfInterfaceListener.class);
+    private static final Splitter DOT_SPLITTER = Splitter.on('.');
 
     private final ListenerRegistration<VppIetfInterfaceListener> registration;
     private final DataBroker db;
@@ -220,7 +222,7 @@ public class VppIetfInterfaceListener implements DataTreeChangeListener<Interfac
         int result = 0;
 
         // iterate over each octet
-        for (String part : address.split("\\.")) {
+        for (String part : DOT_SPLITTER.split(address)) {
             // shift the previously parsed bits over by 1 byte
             result = result << 8;
             // set the low order bits to the current octet