diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-07-19 14:40:57 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-07-19 14:40:57 +0400 |
commit | bc5ecbc393340444344f22489cdffd19a5294528 (patch) | |
tree | c0e2376183598102db599008ed2b02378defdb56 /source/blender/blenlib/intern | |
parent | 3daa153d745766d119f5095baeef55ae570aed03 (diff) |
optimization: avoid extra loop in BLI_mempool_destroy(). free the list inline.
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r-- | source/blender/blenlib/intern/BLI_mempool.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c index 87179a93e83..217a4b9d266 100644 --- a/source/blender/blenlib/intern/BLI_mempool.c +++ b/source/blender/blenlib/intern/BLI_mempool.c @@ -437,19 +437,22 @@ void *BLI_mempool_iterstep(BLI_mempool_iter *iter) void BLI_mempool_destroy(BLI_mempool *pool) { BLI_mempool_chunk *mpchunk = NULL; + BLI_mempool_chunk *mpchunk_next; if (pool->flag & BLI_MEMPOOL_SYSMALLOC) { - for (mpchunk = pool->chunks.first; mpchunk; mpchunk = mpchunk->next) { + for (mpchunk = pool->chunks.first; mpchunk; mpchunk = mpchunk_next) { + mpchunk_next = mpchunk->next; free(mpchunk->data); + free(mpchunk); } - BLI_freelist(&(pool->chunks)); free(pool); } else { - for (mpchunk = pool->chunks.first; mpchunk; mpchunk = mpchunk->next) { + for (mpchunk = pool->chunks.first; mpchunk; mpchunk = mpchunk_next) { + mpchunk_next = mpchunk->next; MEM_freeN(mpchunk->data); + MEM_freeN(mpchunk); } - BLI_freelistN(&(pool->chunks)); MEM_freeN(pool); } } |