Full materialization is completely unnecessary and very wasteful,
just use anyMatch(), terminating search as soon as a match is
found. This should halve (on average) the memory overhead.
Change-Id: Ibc28ef9666360efa09707f6193178d16f49c8f74
JIRA: NETVIRT-1503
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
continue;
}
}
- List<Uuid> rtrIdsList = routerIdsList.stream().map(routerIds -> routerIds.getRouterId())
- .collect(Collectors.toList());
- if (rtrIdsList.contains(routerId)) {
+ // FIXME: NETVIRT-1503: this check can be replaced by a ReadOnlyTransaction.exists()
+ if (routerIdsList.stream().anyMatch(routerIds -> routerId.equals(routerIds.getRouterId()))) {
if (externalVpn) {
if (!routerId.equals(vpnMap.getVpnId())) {
return vpnMap.getVpnId();