]> Sergey Matveev's repositories - btrtrc.git/blobdiff - requesting.go
Simplify request ordering for reversed conditions
[btrtrc.git] / requesting.go
index 027365e381534621eac280b1048633fc4ca49184..eb69549b210e105675b60a9e060446f6f85ba575 100644 (file)
@@ -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]
 }