19 lines
1 KiB
Diff
19 lines
1 KiB
Diff
# UNDF: UNDF-2026-000000743
|
||
# UNDF: (leave blank)
|
||
--- a/xds/src/main/java/io/grpc/xds/client/XdsClientImpl.java
|
||
+++ b/xds/src/main/java/io/grpc/xds/client/XdsClientImpl.java
|
||
@@ -1091,9 +1091,7 @@ public final class XdsClientImpl extends XdsClient {
|
||
private Collection<String> getActiveAuthorities(ControlPlaneClient cpc) {
|
||
- List<String> asList = activatedCpClients.entrySet().stream()
|
||
+ // Always return a HashSet for O(1) contains(); linear scan over asList was O(A×S×T)
|
||
+ // inside double-loops in cleanUpResourceTimers and onControlPlaneClientError.
|
||
+ return activatedCpClients.entrySet().stream()
|
||
.filter(entry -> !entry.getValue().isEmpty()
|
||
&& cpc == entry.getValue().get(entry.getValue().size() - 1))
|
||
.map(Map.Entry::getKey)
|
||
- .collect(Collectors.toList());
|
||
-
|
||
- // Since this is usually used for contains, use a set when the list is large
|
||
- return (asList.size() < 100) ? asList : new HashSet<>(asList);
|
||
+ .collect(Collectors.toCollection(HashSet::new));
|
||
}
|