]> Sergey Matveev's repositories - btrtrc.git/commitdiff
request_strategy.Peer.canRequestPiece performance: Reorder conditions
authorMatt Joiner <anacrolix@gmail.com>
Thu, 16 Sep 2021 07:08:59 +0000 (17:08 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Sat, 18 Sep 2021 02:53:22 +0000 (12:53 +1000)
request-strategy/peer.go

index 21ef0d2eca92e0a54ea0271b3aa2776bf1555efd..b62220641778c291c25281435b7ba9d5a3401018 100644 (file)
@@ -34,5 +34,5 @@ func (p *Peer) pieceAllowedFastOrDefault(i pieceIndex) bool {
 
 // TODO: This might be used in more places I think.
 func (p *Peer) canRequestPiece(i pieceIndex) bool {
-       return p.HasPiece(i) && (!p.Choking || (p.PieceAllowedFast != nil && p.PieceAllowedFast(i)))
+       return (!p.Choking || p.pieceAllowedFastOrDefault(i)) && p.HasPiece(i)
 }