From c3fe2de828576900021d27a52114ebdb0a4cb6f0 Mon Sep 17 00:00:00 2001 From: Dominick Allen Date: Sun, 3 Nov 2024 09:28:13 -0600 Subject: Factor out growth of String and make it scale by 1.5x. --- include/fud_vector.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include/fud_vector.hpp') 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::max(); + if (maxSize - additional * ElementSize < m_capacity * ElementSize) { + additional = maxSize - m_capacity * ElementSize / 2; } while (additional > 0) { auto reserveStatus = reserve(additional + m_capacity); -- cgit v1.2.3