]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Set Torrent.pieces cap too
authorMatt Joiner <anacrolix@gmail.com>
Mon, 23 Jul 2018 00:28:11 +0000 (10:28 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 23 Jul 2018 00:28:11 +0000 (10:28 +1000)
We know exactly how many we want, and don't want to use any more memory.

torrent.go

index 0777373985f49cc726da3f86ccdb0f6cfa0863c0..9aebad9030b9d51c6ead022182adb4f591053536 100644 (file)
@@ -324,7 +324,7 @@ func infoPieceHashes(info *metainfo.Info) (ret []string) {
 
 func (t *Torrent) makePieces() {
        hashes := infoPieceHashes(t.info)
-       t.pieces = make([]Piece, len(hashes))
+       t.pieces = make([]Piece, len(hashes), len(hashes))
        for i, hash := range hashes {
                piece := &t.pieces[i]
                piece.t = t