Avoid the need for floating point arithmetic

closes #2124
This commit is contained in:
Nik Bougalis
2020-11-19 22:31:37 -08:00
committed by Richard Hodges
parent 0e762f1f32
commit 33ea793020
2 changed files with 9 additions and 6 deletions

View File

@@ -1,3 +1,4 @@
* Remove floating point arithmetic requirement.
* Add `cxxstd` to json field.
--------------------------------------------------------------------------------

View File

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