We have an input list, hence we know how big the output will be. Use
that to make sure we do not resize the list.
Change-Id: I6b8c9ec771416b98578820fd8b0b0d5104231c19
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
(cherry picked from commit
21b6b6dbcaa74e71ceb39492b76cc3171e5b6de0)
private DestinationIpv4 prefixes(final ByteBuf nlri) {
final List<Ipv4Prefix> prefs = Ipv4Util.prefixListForBytes(ByteArray.readAllBytes(nlri));
- final List<Ipv4Prefixes> prefixes = new ArrayList<>();
+ final List<Ipv4Prefixes> prefixes = new ArrayList<>(prefs.size());
for (final Ipv4Prefix p : prefs) {
prefixes.add(new Ipv4PrefixesBuilder().setPrefix(p).build());
}
public final class Ipv6NlriParser implements NlriParser {
- private DestinationIpv6 prefixes(final ByteBuf nlri) {
+ private static DestinationIpv6 prefixes(final ByteBuf nlri) {
final List<Ipv6Prefix> prefs = Ipv6Util.prefixListForBytes(ByteArray.readAllBytes(nlri));
- final List<Ipv6Prefixes> prefixes = new ArrayList<>();
+ final List<Ipv6Prefixes> prefixes = new ArrayList<>(prefs.size());
for (final Ipv6Prefix p : prefs) {
prefixes.add(new Ipv6PrefixesBuilder().setPrefix(p).build());
}