]> Sergey Matveev's repositories - btrtrc.git/commitdiff
A CPU optimization to FillRequests when we know no more can be added
authorMatt Joiner <anacrolix@gmail.com>
Mon, 30 Jun 2014 14:03:07 +0000 (00:03 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 30 Jun 2014 14:03:07 +0000 (00:03 +1000)
download_strategies.go

index 2cc7289edb6213d1d50b5579b8f8be3ac2b30c78..8be1be40c5ff38e8647b16a87af4bb989d9c2690 100644 (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]