Optimization for mempool initial chunk allocation
Almost all pools allocated 2 chunks on initialization, every element needed to be added to the free-list which would never be used for small pools. Now allocate only one, gives minor speedup for some bmesh operations.
This commit is contained in:
parent
896725e0bb
commit
7cb90a611f
|
@ -121,10 +121,14 @@ struct BLI_mempool {
|
|||
|
||||
/**
|
||||
* \return the number of chunks to allocate based on how many elements are needed.
|
||||
*
|
||||
* \note for small pools 1 is a good default, the elements need to be initialized,
|
||||
* adding overhead on creation which is redundant if they aren't used.
|
||||
*
|
||||
*/
|
||||
BLI_INLINE unsigned int mempool_maxchunks(const unsigned int totelem, const unsigned int pchunk)
|
||||
{
|
||||
return totelem / pchunk + 1;
|
||||
return (totelem <= pchunk) ? 1 : ((totelem / pchunk) + 1);
|
||||
}
|
||||
|
||||
static BLI_mempool_chunk *mempool_chunk_alloc(BLI_mempool *pool)
|
||||
|
|
Loading…
Reference in New Issue