RoutesAnswerer: faster main rib exact match
This was an existing inefficiency made easier to see and fix by
batfish/batfish#8354. No reason to scan the entire RIB to get matching routes.
commit-id:2d938ad2
@@ -187,12 +187,16 @@ public class RoutesAnswererUtil {
// everything matches if there is not user input
return rib.getRoutes().stream();
}
- if (prefixMatchType == PrefixMatchType.LONGEST_PREFIX_MATCH) {
+ switch (prefixMatchType) {
+ case EXACT:
+ return rib.getRoutes(network).stream();
+ case LONGEST_PREFIX_MATCH:
return rib.longestPrefixMatch(network).stream();
- }
+ default:
return rib.getRoutes().stream()
.filter(r -> prefixMatches(prefixMatchType, network, r.getNetwork()));
}
+ }
@VisibleForTesting
static boolean prefixMatches(
