diff options
author | Dominick Allen <djallen@librehumanitas.org> | 2024-11-03 09:28:13 -0600 |
---|---|---|
committer | Dominick Allen <djallen@librehumanitas.org> | 2024-11-03 09:28:13 -0600 |
commit | c3fe2de828576900021d27a52114ebdb0a4cb6f0 (patch) | |
tree | 34d15165765e15894e2bedbc065081ee1d27ec06 /include/fud_vector.hpp | |
parent | e8422002f84dc4313894a5b3136c44a9005081fd (diff) |
Factor out growth of String and make it scale by 1.5x.
Diffstat (limited to 'include/fud_vector.hpp')
-rw-r--r-- | include/fud_vector.hpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/include/fud_vector.hpp b/include/fud_vector.hpp index 53b2625..a2a0984 100644 --- a/include/fud_vector.hpp +++ b/include/fud_vector.hpp @@ -647,8 +647,9 @@ class Vector { { // See https://github.com/facebook/folly/blob/main/folly/docs/FBVector.md size_t additional = m_capacity < 2 ? 1 : m_capacity / 2; - if (SIZE_MAX - additional * ElementSize < m_capacity * ElementSize) { - additional = SIZE_MAX - m_capacity * ElementSize / 2; + constexpr auto maxSize = std::numeric_limits<size_t>::max(); + if (maxSize - additional * ElementSize < m_capacity * ElementSize) { + additional = maxSize - m_capacity * ElementSize / 2; } while (additional > 0) { auto reserveStatus = reserve(additional + m_capacity); |