Optimize ByteBufUtils.readIetfIpv4Address() 13/94413/3
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 5 Jan 2021 14:37:59 +0000 (15:37 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 5 Jan 2021 16:51:01 +0000 (17:51 +0100)
Use a simple readInt() and pass that down do IetInetUtil, so we
have a more efficient decode.

Change-Id: I9ee229ced8dccf59509c050b0559713d7fcbabde
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
openflowjava/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java

index 1ce82aa164b9a9163b4abfd79b07a83acbbeb942..d5d325fcea5c65743cffdd0b3ec3d36537e9999a 100644 (file)
@@ -136,7 +136,7 @@ public abstract class ByteBufUtils {
      * @param out writing buffer
      * @param index writing index
      */
-    public static void updateOFHeaderLength(final ByteBuf out, int index) {
+    public static void updateOFHeaderLength(final ByteBuf out, final int index) {
         out.setShort(index + EncodeConstants.OFHEADER_LENGTH_INDEX, out.writerIndex() - index);
     }
 
@@ -231,9 +231,7 @@ public abstract class ByteBufUtils {
     }
 
     public static Ipv4Address readIetfIpv4Address(final ByteBuf buf) {
-        final byte[] tmp = new byte[4];
-        buf.readBytes(tmp);
-        return IetfInetUtil.INSTANCE.ipv4AddressFor(tmp);
+        return IetfInetUtil.INSTANCE.ipv4AddressFor(buf.readInt());
     }
 
     public static Ipv6Address readIetfIpv6Address(final ByteBuf buf) {