mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 20:35:36 +00:00
ditch std::lldiv so that functions can take matching parameter types (#5659)
* ditch `std::lldiv` so that functions can take matching parameter types * revert unintended change
This commit is contained in:
@@ -119,12 +119,12 @@ int Cache::write_contiguous(CIter const begin, CIter const end) const
|
||||
return {};
|
||||
}
|
||||
|
||||
size_t Cache::get_max_blocks(int64_t max_bytes) noexcept
|
||||
size_t Cache::get_max_blocks(size_t max_bytes) noexcept
|
||||
{
|
||||
return std::lldiv(max_bytes, tr_block_info::BlockSize).quot;
|
||||
return max_bytes / tr_block_info::BlockSize;
|
||||
}
|
||||
|
||||
int Cache::set_limit(int64_t new_limit)
|
||||
int Cache::set_limit(size_t new_limit)
|
||||
{
|
||||
max_bytes_ = new_limit;
|
||||
max_blocks_ = get_max_blocks(new_limit);
|
||||
@@ -134,7 +134,7 @@ int Cache::set_limit(int64_t new_limit)
|
||||
return cache_trim();
|
||||
}
|
||||
|
||||
Cache::Cache(tr_torrents& torrents, int64_t max_bytes)
|
||||
Cache::Cache(tr_torrents& torrents, size_t max_bytes)
|
||||
: torrents_{ torrents }
|
||||
, max_blocks_(get_max_blocks(max_bytes))
|
||||
, max_bytes_(max_bytes)
|
||||
|
||||
@@ -30,9 +30,9 @@ class Cache
|
||||
public:
|
||||
using BlockData = small::max_size_vector<uint8_t, tr_block_info::BlockSize>;
|
||||
|
||||
Cache(tr_torrents& torrents, int64_t max_bytes);
|
||||
Cache(tr_torrents& torrents, size_t max_bytes);
|
||||
|
||||
int set_limit(int64_t new_limit);
|
||||
int set_limit(size_t new_limit);
|
||||
|
||||
[[nodiscard]] constexpr auto get_limit() const noexcept
|
||||
{
|
||||
@@ -88,7 +88,7 @@ private:
|
||||
// @return any error code from writeContiguous()
|
||||
[[nodiscard]] int cache_trim();
|
||||
|
||||
[[nodiscard]] static size_t get_max_blocks(int64_t max_bytes) noexcept;
|
||||
[[nodiscard]] static size_t get_max_blocks(size_t max_bytes) noexcept;
|
||||
|
||||
[[nodiscard]] CIter get_block(tr_torrent const* torrent, tr_block_info::Location const& loc) noexcept;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user