[Bf-blender-cvs] [737e51c] master: Mempool/Memarena: hint for unlikely conditions

Campbell Barton noreply at git.blender.org
Tue Dec 10 11:29:27 CET 2013


Commit: 737e51cb21cc3864dca3da7e754549e08660f193
Author: Campbell Barton
Date:   Tue Dec 10 21:17:52 2013 +1100
http://developer.blender.org/rB737e51cb21cc3864dca3da7e754549e08660f193

Mempool/Memarena: hint for unlikely conditions

===================================================================

M	source/blender/blenlib/intern/BLI_memarena.c
M	source/blender/blenlib/intern/BLI_mempool.c

===================================================================

diff --git a/source/blender/blenlib/intern/BLI_memarena.c b/source/blender/blenlib/intern/BLI_memarena.c
index ce04ac6..dd0997c 100644
--- a/source/blender/blenlib/intern/BLI_memarena.c
+++ b/source/blender/blenlib/intern/BLI_memarena.c
@@ -117,7 +117,7 @@ void *BLI_memarena_alloc(MemArena *ma, size_t size)
 	 * size up to multiple of 8 */
 	size = PADUP(size, ma->align);
 
-	if (size > ma->cursize) {
+	if (UNLIKELY(size > ma->cursize)) {
 		if (size > ma->bufsize - (ma->align - 1)) {
 			ma->cursize = PADUP(size + 1, ma->align);
 		}
diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c
index c2b5402..1321f00 100644
--- a/source/blender/blenlib/intern/BLI_mempool.c
+++ b/source/blender/blenlib/intern/BLI_mempool.c
@@ -295,7 +295,7 @@ void *BLI_mempool_alloc(BLI_mempool *pool)
 
 	pool->totused++;
 
-	if (!(pool->free)) {
+	if (UNLIKELY(pool->free == NULL)) {
 		/* need to allocate a new chunk */
 		BLI_mempool_chunk *mpchunk = mempool_chunk_alloc(pool);
 		mempool_chunk_add(pool, mpchunk, NULL);




More information about the Bf-blender-cvs mailing list