mirror of
https://github.com/transmission/transmission.git
synced 2026-05-03 23:25:14 +01:00
perf: avoid extra heap alloc in block cache (#5522)
This commit is contained in:
@@ -224,7 +224,7 @@ struct tr_incoming
|
||||
struct incoming_piece_data
|
||||
{
|
||||
explicit incoming_piece_data(uint32_t block_size)
|
||||
: buf{ std::make_unique<std::vector<uint8_t>>(block_size) }
|
||||
: buf{ std::make_unique<Cache::BlockData>(block_size) }
|
||||
, block_size_{ block_size }
|
||||
{
|
||||
}
|
||||
@@ -249,7 +249,7 @@ struct tr_incoming
|
||||
return have_.count() >= block_size_;
|
||||
}
|
||||
|
||||
std::unique_ptr<std::vector<uint8_t>> buf;
|
||||
std::unique_ptr<Cache::BlockData> buf;
|
||||
|
||||
private:
|
||||
std::bitset<tr_block_info::BlockSize> have_;
|
||||
@@ -1347,7 +1347,7 @@ void peerMadeRequest(tr_peerMsgsImpl* msgs, struct peer_request const* req)
|
||||
}
|
||||
}
|
||||
|
||||
int clientGotBlock(tr_peerMsgsImpl* msgs, std::unique_ptr<std::vector<uint8_t>> block_data, tr_block_index_t block);
|
||||
int clientGotBlock(tr_peerMsgsImpl* msgs, std::unique_ptr<Cache::BlockData> block_data, tr_block_index_t block);
|
||||
|
||||
ReadResult read_piece_data(tr_peerMsgsImpl* msgs, PeerMessageReader& payload)
|
||||
{
|
||||
@@ -1645,7 +1645,7 @@ ReadResult process_peer_message(tr_peerMsgsImpl* msgs, uint8_t id, PeerMessageRe
|
||||
}
|
||||
|
||||
/* returns 0 on success, or an errno on failure */
|
||||
int clientGotBlock(tr_peerMsgsImpl* msgs, std::unique_ptr<std::vector<uint8_t>> block_data, tr_block_index_t const block)
|
||||
int clientGotBlock(tr_peerMsgsImpl* msgs, std::unique_ptr<Cache::BlockData> block_data, tr_block_index_t const block)
|
||||
{
|
||||
TR_ASSERT(msgs != nullptr);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user