Break up long condition expression

This commit is contained in:
Matt Joiner 2024-01-15 12:44:33 +11:00
parent 70ce33cab3
commit 6e8634e971
No known key found for this signature in database
GPG Key ID: 6B990B8185E7F782
1 changed files with 8 additions and 1 deletions

View File

@ -260,7 +260,14 @@ func (p *Peer) applyRequestState(next desiredRequestState) {
t := p.t
originalRequestCount := current.Requests.GetCardinality()
for requestHeap.Len() != 0 && maxRequests(current.Requests.GetCardinality()+current.Cancelled.GetCardinality()) < p.nominalMaxRequests() {
for {
if requestHeap.Len() == 0 {
break
}
numPending := maxRequests(current.Requests.GetCardinality() + current.Cancelled.GetCardinality())
if numPending >= p.nominalMaxRequests() {
break
}
req := heap.Pop(requestHeap)
existing := t.requestingPeer(req)
if existing != nil && existing != p {