From da80a8cf6ae3f2993d86c2c328b099078e037c96 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 3 Mar 2021 20:51:24 +1100 Subject: [PATCH] Raise ThreadedVM initial thread capacity to 16 Threads are 4 bytes, an initial capacity of 4 led to allocating 16 bytes, raising that to 64 bytes seems quite reasonable. --- src/regex_impl.hh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/regex_impl.hh b/src/regex_impl.hh index 13c48c09..d73c7aa6 100644 --- a/src/regex_impl.hh +++ b/src/regex_impl.hh @@ -658,7 +658,11 @@ private: { if (m_current != m_next) return; - const auto new_capacity = m_capacity ? m_capacity * 2 : 4; + + constexpr int32_t initial_capacity = 64 / sizeof(Thread); + static_assert(initial_capacity >= 4); + + const auto new_capacity = m_capacity ? m_capacity * 2 : initial_capacity; const auto next_count = m_capacity - m_next; const auto new_next = new_capacity - next_count; Thread* new_data = new Thread[new_capacity];