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:
tearfur 2023-06-26 02:29:58 +08:00 committed by GitHub
parent dc88b97f37
commit ed02f98014
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -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)

View File

@ -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;