Avoid the need for floating point arithmetic

closes #2124
This commit is contained in:
Nik Bougalis authored and Richard Hodges committed 2020-12-16 18:31:36 +01:00
1 parent 0e762f1f32
commit 33ea793020
2 files changed
+9 -6

No files matched your search

@@ -912,15 +912,17 @@ prepare(size_type n) ->
destroy(reuse);
if(n > 0)
{
auto const growth_factor = 2.0f;
std::size_t const growth_factor = 2;
std::size_t altn = in_size_ * growth_factor;
// Overflow detection:
if(in_size_ > altn)
altn = std::numeric_limits<std::size_t>::max();
else
altn = (std::max<std::size_t>)(512, altn);
auto const size =
(std::min<std::size_t>)(
max_ - total,
(std::max<std::size_t>)({
static_cast<std::size_t>(
in_size_ * growth_factor - in_size_),
512,
n}));
(std::max<std::size_t>)(n, altn));
auto& e = alloc(size);
list_.push_back(e);
if(out_ == list_.end())