BUg-2825: optimize prefixForBytes/prefixForByteBuf 44/35944/4
authorRobert Varga <robert.varga@pantheon.sk>
Thu, 25 Feb 2016 20:02:33 +0000 (21:02 +0100)
committerRobert Varga <rovarga@cisco.com>
Wed, 9 Mar 2016 09:38:40 +0000 (10:38 +0100)
commitda0a65a75a74d704341a018da555c9fe1bdd6ed7
tree638139c0470e2198e133ca89799c7ae5b14b8f87
parent2f99f944ca2f319dafc49ed23472253495b0ff59
BUg-2825: optimize prefixForBytes/prefixForByteBuf

Instead of always performing a copy, copy the array only on size
mismatch.

In prefixForByteBuf, allocate a bytearray which has correct size and
read into it -- the rest of it will be zero-initialized, just as it
should be.

Change-Id: I1e71e98e3efba2d731bb8be2c6cfb8062dec00e2
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
(cherry picked from commit 4d5062600e78c4b8c3c2d0e85d454f72f67b8104)
util/src/main/java/org/opendaylight/protocol/util/Ipv4Util.java
util/src/main/java/org/opendaylight/protocol/util/Ipv6Util.java