Optimize IpConversionUtil.extractIpv4AddressMask() 44/80544/7
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 22 Feb 2019 13:14:11 +0000 (14:14 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 7 Mar 2019 10:41:13 +0000 (11:41 +0100)
commit764338e1e77a803661d9b779426a9fe3cb4e0696
tree189629d9b68c75690db33609088883907673a7f3
parent0ce8ccc0e8bf37d844416f675c7120247ad0fbdc
Optimize IpConversionUtil.extractIpv4AddressMask()

Rather than going through String.format() use simple pre-allocated
StringBuilder.

Furthermore, Ipv4Prefix is guaranteed to always contain a slash,
hence we can use a simple indexOf/substring instead of splitting
the string.

Finally, if the prefix is 32, we can reuse the DottedQuad we keep
around for full arbitrary mask.

JIRA: OPNFLWPLUG-1067
Change-Id: I99f036c86606142a9f844507789293cd9822692f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/IpConversionUtil.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/IpConversionUtilTest.java