Skip to content

Commit 1435323

Browse files
authored
core: Avoid Set.removeAll() when passing a possibly-large List (#11994) (#12001)
See #11958
1 parent 8cc0d4c commit 1435323

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

core/src/main/java/io/grpc/internal/DelayedClientTransport.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,11 @@ final void reprocess(@Nullable SubchannelPicker picker) {
325325
if (!hasPendingStreams()) {
326326
return;
327327
}
328-
pendingStreams.removeAll(toRemove);
328+
// Avoid pendingStreams.removeAll() as it can degrade to calling toRemove.contains() for each
329+
// element in pendingStreams.
330+
for (PendingStream stream : toRemove) {
331+
pendingStreams.remove(stream);
332+
}
329333
// Because delayed transport is long-lived, we take this opportunity to down-size the
330334
// hashmap.
331335
if (pendingStreams.isEmpty()) {

0 commit comments

Comments
 (0)