Several speedups in logic
This commit is contained in:
parent
6c04000644
commit
0600c3b5e3
10
client.go
10
client.go
|
@ -1749,8 +1749,11 @@ func (t *torrent) needData() bool {
|
|||
if !t.haveInfo() {
|
||||
return true
|
||||
}
|
||||
for i := range t.Pieces {
|
||||
if t.wantPiece(i) {
|
||||
if len(t.urgent) != 0 {
|
||||
return true
|
||||
}
|
||||
for _, p := range t.Pieces {
|
||||
if p.Priority != PiecePriorityNone {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -2618,8 +2621,7 @@ func (me *Client) pieceChanged(t *torrent, piece int) {
|
|||
}
|
||||
}
|
||||
conn.pieceRequestOrder.DeletePiece(int(piece))
|
||||
}
|
||||
if t.wantPiece(piece) && conn.PeerHasPiece(piece) {
|
||||
} else if t.wantPiece(piece) && conn.PeerHasPiece(piece) {
|
||||
t.connPendPiece(conn, int(piece))
|
||||
me.replenishConnRequests(t, conn)
|
||||
}
|
||||
|
|
|
@ -307,7 +307,7 @@ func (t *torrent) pieceState(index int) (ret PieceState) {
|
|||
if p.QueuedForHash || p.Hashing {
|
||||
ret.Checking = true
|
||||
}
|
||||
if t.piecePartiallyDownloaded(index) {
|
||||
if !ret.Complete && t.piecePartiallyDownloaded(index) {
|
||||
ret.Partial = true
|
||||
}
|
||||
return
|
||||
|
@ -674,7 +674,13 @@ func (t *torrent) haveChunk(r request) bool {
|
|||
if !t.haveInfo() {
|
||||
return false
|
||||
}
|
||||
if t.pieceComplete(int(r.Index)) {
|
||||
return true
|
||||
}
|
||||
p := t.Pieces[r.Index]
|
||||
if p.PendingChunkSpecs == nil {
|
||||
return false
|
||||
}
|
||||
return !p.pendingChunk(r.chunkSpec, t.chunkSize)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue