mirror of
https://github.com/transmission/transmission
synced 2025-03-04 02:28:03 +00:00
perf: pass by reference (#4876)
This commit is contained in:
parent
d445c7f061
commit
68e965aa28
6 changed files with 17 additions and 17 deletions
|
@ -419,7 +419,7 @@ struct tr_tier
|
|||
return currentTracker();
|
||||
}
|
||||
|
||||
[[nodiscard]] std::optional<size_t> indexOf(tr_interned_string const& announce_url) const
|
||||
[[nodiscard]] std::optional<size_t> indexOf(tr_interned_string announce_url) const
|
||||
{
|
||||
for (size_t i = 0, n = std::size(trackers); i < n; ++i)
|
||||
{
|
||||
|
@ -579,7 +579,7 @@ struct tr_torrent_announcer
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
tr_tier* getTierFromScrape(tr_interned_string const& scrape_url)
|
||||
tr_tier* getTierFromScrape(tr_interned_string scrape_url)
|
||||
{
|
||||
for (auto& tier : tiers)
|
||||
{
|
||||
|
@ -600,7 +600,7 @@ struct tr_torrent_announcer
|
|||
}
|
||||
|
||||
[[nodiscard]] bool findTracker(
|
||||
tr_interned_string const& announce_url,
|
||||
tr_interned_string announce_url,
|
||||
tr_tier const** setme_tier,
|
||||
tr_tracker const** setme_tracker) const
|
||||
{
|
||||
|
|
|
@ -161,7 +161,7 @@ int Cache::writeBlock(tr_torrent_id_t tor_id, tr_block_index_t block, std::uniqu
|
|||
return cacheTrim();
|
||||
}
|
||||
|
||||
Cache::CIter Cache::getBlock(tr_torrent const* torrent, tr_block_info::Location loc) noexcept
|
||||
Cache::CIter Cache::getBlock(tr_torrent const* torrent, tr_block_info::Location const& loc) noexcept
|
||||
{
|
||||
if (auto const [begin, end] = std::equal_range(
|
||||
std::begin(blocks_),
|
||||
|
@ -176,7 +176,7 @@ Cache::CIter Cache::getBlock(tr_torrent const* torrent, tr_block_info::Location
|
|||
return std::end(blocks_);
|
||||
}
|
||||
|
||||
int Cache::readBlock(tr_torrent* torrent, tr_block_info::Location loc, uint32_t len, uint8_t* setme)
|
||||
int Cache::readBlock(tr_torrent* torrent, tr_block_info::Location const& loc, uint32_t len, uint8_t* setme)
|
||||
{
|
||||
if (auto const iter = getBlock(torrent, loc); iter != std::end(blocks_))
|
||||
{
|
||||
|
@ -187,7 +187,7 @@ int Cache::readBlock(tr_torrent* torrent, tr_block_info::Location loc, uint32_t
|
|||
return tr_ioRead(torrent, loc, len, setme);
|
||||
}
|
||||
|
||||
int Cache::prefetchBlock(tr_torrent* torrent, tr_block_info::Location loc, uint32_t len)
|
||||
int Cache::prefetchBlock(tr_torrent* torrent, tr_block_info::Location const& loc, uint32_t len)
|
||||
{
|
||||
if (auto const iter = getBlock(torrent, loc); iter != std::end(blocks_))
|
||||
{
|
||||
|
|
|
@ -38,8 +38,8 @@ public:
|
|||
// @return any error code from cacheTrim()
|
||||
int writeBlock(tr_torrent_id_t tor, tr_block_index_t block, std::unique_ptr<std::vector<uint8_t>> writeme);
|
||||
|
||||
int readBlock(tr_torrent* torrent, tr_block_info::Location loc, uint32_t len, uint8_t* setme);
|
||||
int prefetchBlock(tr_torrent* torrent, tr_block_info::Location loc, uint32_t len);
|
||||
int readBlock(tr_torrent* torrent, tr_block_info::Location const& loc, uint32_t len, uint8_t* setme);
|
||||
int prefetchBlock(tr_torrent* torrent, tr_block_info::Location const& loc, uint32_t len);
|
||||
int flushTorrent(tr_torrent const* torrent);
|
||||
int flushFile(tr_torrent const* torrent, tr_file_index_t file);
|
||||
|
||||
|
@ -86,7 +86,7 @@ private:
|
|||
|
||||
[[nodiscard]] static size_t getMaxBlocks(int64_t max_bytes) noexcept;
|
||||
|
||||
[[nodiscard]] CIter getBlock(tr_torrent const* torrent, tr_block_info::Location loc) noexcept;
|
||||
[[nodiscard]] CIter getBlock(tr_torrent const* torrent, tr_block_info::Location const& loc) noexcept;
|
||||
|
||||
tr_torrents& torrents_;
|
||||
|
||||
|
|
|
@ -282,17 +282,17 @@ std::optional<tr_sha1_digest_t> recalculateHash(tr_torrent* tor, tr_piece_index_
|
|||
|
||||
} // namespace
|
||||
|
||||
int tr_ioRead(tr_torrent* tor, tr_block_info::Location loc, size_t len, uint8_t* setme)
|
||||
int tr_ioRead(tr_torrent* tor, tr_block_info::Location const& loc, size_t len, uint8_t* setme)
|
||||
{
|
||||
return readOrWritePiece(tor, IoMode::Read, loc, setme, len);
|
||||
}
|
||||
|
||||
int tr_ioPrefetch(tr_torrent* tor, tr_block_info::Location loc, size_t len)
|
||||
int tr_ioPrefetch(tr_torrent* tor, tr_block_info::Location const& loc, size_t len)
|
||||
{
|
||||
return readOrWritePiece(tor, IoMode::Prefetch, loc, nullptr, len);
|
||||
}
|
||||
|
||||
int tr_ioWrite(tr_torrent* tor, tr_block_info::Location loc, size_t len, uint8_t const* writeme)
|
||||
int tr_ioWrite(tr_torrent* tor, tr_block_info::Location const& loc, size_t len, uint8_t const* writeme)
|
||||
{
|
||||
return readOrWritePiece(tor, IoMode::Write, loc, const_cast<uint8_t*>(writeme), len);
|
||||
}
|
||||
|
|
|
@ -26,15 +26,15 @@ struct tr_torrent;
|
|||
* Reads the block specified by the piece index, offset, and length.
|
||||
* @return 0 on success, or an errno value on failure.
|
||||
*/
|
||||
[[nodiscard]] int tr_ioRead(struct tr_torrent* tor, tr_block_info::Location loc, size_t len, uint8_t* setme);
|
||||
[[nodiscard]] int tr_ioRead(struct tr_torrent* tor, tr_block_info::Location const& loc, size_t len, uint8_t* setme);
|
||||
|
||||
int tr_ioPrefetch(tr_torrent* tor, tr_block_info::Location loc, size_t len);
|
||||
int tr_ioPrefetch(tr_torrent* tor, tr_block_info::Location const& loc, size_t len);
|
||||
|
||||
/**
|
||||
* Writes the block specified by the piece index, offset, and length.
|
||||
* @return 0 on success, or an errno value on failure.
|
||||
*/
|
||||
[[nodiscard]] int tr_ioWrite(struct tr_torrent* tor, tr_block_info::Location loc, size_t len, uint8_t const* writeme);
|
||||
[[nodiscard]] int tr_ioWrite(struct tr_torrent* tor, tr_block_info::Location const& loc, size_t len, uint8_t const* writeme);
|
||||
|
||||
/**
|
||||
* @brief Test to see if the piece matches its metainfo's SHA1 checksum.
|
||||
|
|
|
@ -2559,8 +2559,8 @@ void renameTorrentFileString(tr_torrent* tor, std::string_view oldpath, std::str
|
|||
|
||||
void torrentRenamePath(
|
||||
tr_torrent* const tor,
|
||||
std::string oldpath, // NOLINT performance-unnecessary-value-param
|
||||
std::string newname, // NOLINT performance-unnecessary-value-param
|
||||
std::string const& oldpath, // NOLINT performance-unnecessary-value-param
|
||||
std::string const& newname, // NOLINT performance-unnecessary-value-param
|
||||
tr_torrent_rename_done_func callback,
|
||||
void* const callback_user_data)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue