[Bf-blender-cvs] [2c5dc66] master: Optimize mempool iteration
Campbell Barton
noreply at git.blender.org
Wed Jun 1 16:07:50 CEST 2016
Commit: 2c5dc66d5effd4072f438afb93d70546891ea98e
Author: Campbell Barton
Date: Thu Jun 2 00:04:51 2016 +1000
Branches: master
https://developer.blender.org/rB2c5dc66d5effd4072f438afb93d70546891ea98e
Optimize mempool iteration
Around ~10% improvement in own tests.
===================================================================
M source/blender/blenlib/intern/BLI_mempool.c
===================================================================
diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c
index 38d1575..b7a51f2 100644
--- a/source/blender/blenlib/intern/BLI_mempool.c
+++ b/source/blender/blenlib/intern/BLI_mempool.c
@@ -605,19 +605,26 @@ void *BLI_mempool_iterstep(BLI_mempool_iter *iter)
*/
void *BLI_mempool_iterstep(BLI_mempool_iter *iter)
{
- BLI_freenode *ret;
+ if (UNLIKELY(iter->curchunk == NULL)) {
+ return NULL;
+ }
+ const unsigned int esize = iter->pool->esize;
+ BLI_freenode *curnode = POINTER_OFFSET(CHUNK_DATA(iter->curchunk), (esize * iter->curindex));
+ BLI_freenode *ret;
do {
- if (LIKELY(iter->curchunk)) {
- ret = (BLI_freenode *)(((char *)CHUNK_DATA(iter->curchunk)) + (iter->pool->esize * iter->curindex));
+ ret = curnode;
+
+ if (++iter->curindex != iter->pool->pchunk) {
+ curnode = POINTER_OFFSET(curnode, esize);
}
else {
- return NULL;
- }
-
- if (UNLIKELY(++iter->curindex == iter->pool->pchunk)) {
iter->curindex = 0;
iter->curchunk = iter->curchunk->next;
+ if (iter->curchunk == NULL) {
+ return NULL;
+ }
+ curnode = CHUNK_DATA(iter->curchunk);
}
} while (ret->freeword == FREEWORD);
More information about the Bf-blender-cvs
mailing list