]> Sergey Matveev's repositories - btrtrc.git/blobdiff - request-strategy/peer.go
request_strategy.Peer.canRequestPiece performance: Reorder conditions
[btrtrc.git] / 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)
 }