From 0a8e66c7fce726de4dbbcaf33446413e965c17a0 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Tue, 12 Oct 2021 12:31:47 +1100 Subject: [PATCH] Simplify request ordering for reversed conditions --- requesting.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/requesting.go b/requesting.go index 027365e3..eb69549b 100644 --- a/requesting.go +++ b/requesting.go @@ -159,10 +159,11 @@ func (p peerRequests) Less(i, j int) bool { ml = ml.Int( pending(leftRequest, leftCurrent), pending(rightRequest, rightCurrent)) - ml = ml.Bool(rightCurrent, leftCurrent) + ml = ml.Bool(!leftCurrent, !rightCurrent) ml = ml.Int( - int(p.torrentStrategyInput.Pieces[rightPieceIndex].Priority), - int(p.torrentStrategyInput.Pieces[leftPieceIndex].Priority)) + -int(p.torrentStrategyInput.Pieces[leftPieceIndex].Priority), + -int(p.torrentStrategyInput.Pieces[rightPieceIndex].Priority), + ) ml = ml.Int( int(p.torrentStrategyInput.Pieces[leftPieceIndex].Availability), int(p.torrentStrategyInput.Pieces[rightPieceIndex].Availability)) @@ -171,7 +172,7 @@ func (p peerRequests) Less(i, j int) bool { return ml.MustLess() } -func (p peerRequests) Swap(i, j int) { +func (p *peerRequests) Swap(i, j int) { p.requestIndexes[i], p.requestIndexes[j] = p.requestIndexes[j], p.requestIndexes[i] } -- 2.48.1