[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [42959] branches/bmesh/blender/source/ blender/blenlib/intern/BLI_mempool.c: optimized version of BLI_mempool_iterstep() which uses branch pradiction to get a little bit more performance, since this is used for looping on all mesh data elements
Campbell Barton
ideasman42 at gmail.com
Thu Dec 29 03:55:29 CET 2011
Revision: 42959
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42959
Author: campbellbarton
Date: 2011-12-29 02:55:20 +0000 (Thu, 29 Dec 2011)
Log Message:
-----------
optimized version of BLI_mempool_iterstep() which uses branch pradiction to get a little bit more performance, since this is used for looping on all mesh data elements
Modified Paths:
--------------
branches/bmesh/blender/source/blender/blenlib/intern/BLI_mempool.c
Modified: branches/bmesh/blender/source/blender/blenlib/intern/BLI_mempool.c
===================================================================
--- branches/bmesh/blender/source/blender/blenlib/intern/BLI_mempool.c 2011-12-29 01:58:47 UTC (rev 42958)
+++ branches/bmesh/blender/source/blender/blenlib/intern/BLI_mempool.c 2011-12-29 02:55:20 UTC (rev 42959)
@@ -274,6 +274,9 @@
iter->curindex = 0;
}
+#if 0
+/* unoptimized, more readable */
+
static void *bli_mempool_iternext(BLI_mempool_iter *iter)
{
void *ret = NULL;
@@ -303,6 +306,37 @@
return ret;
}
+#else
+
+/* optimized version of code above */
+
+void *BLI_mempool_iterstep(BLI_mempool_iter *iter)
+{
+ BLI_freenode *ret;
+
+ if (UNLIKELY(iter->pool->totused == 0)) {
+ return NULL;
+ }
+
+ do {
+ if (LIKELY(iter->curchunk)) {
+ ret = (BLI_freenode *)(((char*)iter->curchunk->data) + iter->pool->esize*iter->curindex);
+ }
+ else {
+ return NULL;
+ }
+
+ if (UNLIKELY(++iter->curindex >= iter->pool->pchunk)) {
+ iter->curindex = 0;
+ iter->curchunk = iter->curchunk->next;
+ }
+ } while (ret->freeword == FREEWORD);
+
+ return ret;
+}
+
+#endif
+
void BLI_mempool_destroy(BLI_mempool *pool)
{
BLI_mempool_chunk *mpchunk=NULL;
More information about the Bf-blender-cvs
mailing list