From: Matt Joiner Date: Mon, 30 Jun 2014 14:03:07 +0000 (+1000) Subject: A CPU optimization to FillRequests when we know no more can be added X-Git-Tag: v1.0.0~1691 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=147ad311358e7229781746748da5a40fb4d3c392;p=btrtrc.git A CPU optimization to FillRequests when we know no more can be added --- diff --git a/download_strategies.go b/download_strategies.go index 2cc7289e..8be1be40 100644 --- a/download_strategies.go +++ b/download_strategies.go @@ -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]