request_strategy.Peer.canRequestPiece performance: Reorder conditions

This commit is contained in:
Matt Joiner 2021-09-16 17:08:59 +10:00
parent 7b19e81fc6
commit dd52a1440f
1 changed files with 1 additions and 1 deletions

View 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)
}