A CPU optimization to FillRequests when we know no more can be added

This commit is contained in:
Matt Joiner 2014-07-01 00:03:07 +10:00
parent b969b17092
commit 147ad31135
1 changed files with 8 additions and 0 deletions

View File

@ -16,6 +16,14 @@ type DefaultDownloadStrategy struct {
}
func (s *DefaultDownloadStrategy) FillRequests(t *torrent, c *connection) {
if c.Interested {
if c.PeerChoked {
return
}
if len(c.Requests) >= c.PeerMaxRequests {
return
}
}
th := s.heat[t]
addRequest := func(req request) (again bool) {
piece := t.Pieces[req.Index]