requesting.go | 11 +++++------ diff --git a/requesting.go b/requesting.go index 2c7b4582452c8c3012a3bf36b0a8bcbc2fa74342..dbb51730b49511d90639cde7a316c83559c44529 100644 --- a/requesting.go +++ b/requesting.go @@ -4,6 +4,7 @@ import ( "time" "unsafe" + "github.com/RoaringBitmap/roaring" "github.com/anacrolix/missinggo/v2/bitmap" "github.com/anacrolix/chansync" @@ -208,12 +209,10 @@ if !p.setInterested(next.Interested) { return false } more := true - current.Requests.Iterate(func(req uint32) bool { - if !next.Requests.Contains(req) { - more = p.cancel(req) - return more - } - return true + cancel := roaring.AndNot(¤t.Requests, &next.Requests) + cancel.Iterate(func(req uint32) bool { + more = p.cancel(req) + return more }) if !more { return false