From 6e8634e97172224857134b425358521c84517e02 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Mon, 15 Jan 2024 12:44:33 +1100 Subject: [PATCH] Break up long condition expression --- requesting.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/requesting.go b/requesting.go index d961fba4..b70f2645 100644 --- a/requesting.go +++ b/requesting.go @@ -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 { -- 2.48.1