2
0
mirror of synced 2025-02-24 14:48:27 +00:00
Jonathan McDowell a1a820d3c9
Avoid heap allocation in GetRequestablePieces (#734)
The calculation of whether we should ignore a piece in
GetRequestablePieces ends up doing an allocation for every piece, when
all we really need to do is query the index in the torrent. Provide an
IgnorePiece function instead, which avoids the need for a temporary
allocation.

Observed to cut out 40% of object allocations in some workloads (large
download, lots of seeds).
2022-04-11 14:22:05 +10:00

8 lines
122 B
Go

package request_strategy
type Torrent interface {
IgnorePiece(int) bool
ChunksPerPiece() uint32
PieceLength() int64
}