Make sure no vector reallocation will be performed on pillars.

This is a workaround for now, it needs to be handled properly.
This commit is contained in:
tamasmeszaros 2019-10-03 15:13:17 +02:00
parent c4d50ea639
commit fefde79c89

View File

@ -309,7 +309,7 @@ public:
{
std::lock_guard<Mutex> lk(m_mutex);
if (m_pillars.capacity() < m_heads.size())
m_pillars.reserve(m_heads.size() * 2);
m_pillars.reserve(m_heads.size() * 10);
assert(headid >= 0 && headid < m_head_indices.size());
Head &head = m_heads[m_head_indices[size_t(headid)]];
@ -360,7 +360,8 @@ public:
{
std::lock_guard<Mutex> lk(m_mutex);
if (m_pillars.capacity() < m_heads.size())
m_pillars.reserve(m_heads.size() * 2);
m_pillars.reserve(m_heads.size() * 10);
m_pillars.emplace_back(std::forward<Args>(args)...);
Pillar& pillar = m_pillars.back();
pillar.id = long(m_pillars.size() - 1);