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:
parent
dc88b97f37
commit
ed02f98014
|
@ -119,12 +119,12 @@ int Cache::write_contiguous(CIter const begin, CIter const end) const
|
||||||
return {};
|
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_bytes_ = new_limit;
|
||||||
max_blocks_ = get_max_blocks(new_limit);
|
max_blocks_ = get_max_blocks(new_limit);
|
||||||
|
@ -134,7 +134,7 @@ int Cache::set_limit(int64_t new_limit)
|
||||||
return cache_trim();
|
return cache_trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
Cache::Cache(tr_torrents& torrents, int64_t max_bytes)
|
Cache::Cache(tr_torrents& torrents, size_t max_bytes)
|
||||||
: torrents_{ torrents }
|
: torrents_{ torrents }
|
||||||
, max_blocks_(get_max_blocks(max_bytes))
|
, max_blocks_(get_max_blocks(max_bytes))
|
||||||
, max_bytes_(max_bytes)
|
, max_bytes_(max_bytes)
|
||||||
|
|
|
@ -30,9 +30,9 @@ class Cache
|
||||||
public:
|
public:
|
||||||
using BlockData = small::max_size_vector<uint8_t, tr_block_info::BlockSize>;
|
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
|
[[nodiscard]] constexpr auto get_limit() const noexcept
|
||||||
{
|
{
|
||||||
|
@ -88,7 +88,7 @@ private:
|
||||||
// @return any error code from writeContiguous()
|
// @return any error code from writeContiguous()
|
||||||
[[nodiscard]] int cache_trim();
|
[[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;
|
[[nodiscard]] CIter get_block(tr_torrent const* torrent, tr_block_info::Location const& loc) noexcept;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue