core: Avoid Set.removeAll() when passing a possibly-large List (#11994) (#12000)

See #11958
This commit is contained in:
Eric Anderson 2025-04-07 06:08:23 -07:00 committed by GitHub
parent 2448c8b6b9
commit 666136b4b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 1 deletions

View File

@ -325,7 +325,11 @@ final class DelayedClientTransport implements ManagedClientTransport {
if (!hasPendingStreams()) {
return;
}
pendingStreams.removeAll(toRemove);
// Avoid pendingStreams.removeAll() as it can degrade to calling toRemove.contains() for each
// element in pendingStreams.
for (PendingStream stream : toRemove) {
pendingStreams.remove(stream);
}
// Because delayed transport is long-lived, we take this opportunity to down-size the
// hashmap.
if (pendingStreams.isEmpty()) {