Fitted zone vectors are now magic vectors.

The pointed-to zones in the original children vector can't be freed, so
they are put into a zone pool for re-use by future zones.
This commit is contained in:
Bartosz Taudul 2019-11-10 21:35:41 +01:00
parent 4f962d2fcc
commit ae33aa4869

View File

@ -3647,8 +3647,16 @@ void Worker::ProcessZoneEnd( const QueueZoneEnd& ev )
if( sz <= 8 * 1024 )
{
Vector<short_ptr<ZoneEvent>> fitVec;
fitVec.reserve_exact( sz, m_slab );
memcpy( fitVec.data(), childVec.data(), sz * sizeof( short_ptr<ZoneEvent> ) );
fitVec.set_magic();
auto& fv = *((Vector<ZoneEvent>*)&fitVec);
fv.reserve_exact( sz, m_slab );
auto dst = fv.data();
for( auto& ze : childVec )
{
ZoneEvent* src = ze;
memcpy( dst++, src, sizeof( ZoneEvent ) );
m_zoneEventPool.push_back( src );
}
fitVec.swap( childVec );
m_data.zoneVectorCache.push_back( std::move( fitVec ) );
}