mirror of
https://github.com/transmission/transmission.git
synced 2025-12-27 05:38:40 +00:00
perf: avoid extra heap alloc in block cache (#5522)
This commit is contained in:
@@ -76,7 +76,7 @@ TEST_P(IncompleteDirTest, incompleteDir)
|
||||
tr_torrent* tor = {};
|
||||
tr_block_index_t block = {};
|
||||
tr_piece_index_t pieceIndex = {};
|
||||
std::unique_ptr<std::vector<uint8_t>> buf = {};
|
||||
std::unique_ptr<Cache::BlockData> buf = {};
|
||||
bool done = {};
|
||||
};
|
||||
|
||||
@@ -97,7 +97,8 @@ TEST_P(IncompleteDirTest, incompleteDir)
|
||||
|
||||
for (tr_block_index_t block_index = begin; block_index < end; ++block_index)
|
||||
{
|
||||
data.buf = std::make_unique<std::vector<uint8_t>>(tr_block_info::BlockSize, '\0');
|
||||
data.buf = std::make_unique<Cache::BlockData>(tr_block_info::BlockSize);
|
||||
std::fill_n(std::data(*data.buf), tr_block_info::BlockSize, '\0');
|
||||
data.block = block_index;
|
||||
data.done = false;
|
||||
session_->runInSessionThread(test_incomplete_dir_threadfunc, &data);
|
||||
|
||||
Reference in New Issue
Block a user