[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45100] trunk/blender/source/blender/bmesh /intern/bmesh_core.c: minor speedup to vertex split function, avoid a hash lookup when its not needed.

Campbell Barton ideasman42 at gmail.com
Fri Mar 23 06:18:12 CET 2012


Revision: 45100
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45100
Author:   campbellbarton
Date:     2012-03-23 05:18:03 +0000 (Fri, 23 Mar 2012)
Log Message:
-----------
minor speedup to vertex split function, avoid a hash lookup when its not needed.

Modified Paths:
--------------
    trunk/blender/source/blender/bmesh/intern/bmesh_core.c

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_core.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_core.c	2012-03-23 03:21:59 UTC (rev 45099)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_core.c	2012-03-23 05:18:03 UTC (rev 45100)
@@ -1784,6 +1784,7 @@
 
 		maxindex++;
 	}
+	BLI_array_free(stack);
 
 	/* Make enough verts to split v for each group */
 	verts = MEM_callocN(sizeof(BMVert *) * maxindex, __func__);
@@ -1794,6 +1795,10 @@
 
 	/* Replace v with the new verts in each group */
 	BM_ITER(l, &liter, bm, BM_LOOPS_OF_VERT, v) {
+		/* call first since its faster then a hash lookup */
+		if (l->v != v) {
+			continue;
+		}
 		i = GET_INT_FROM_POINTER(BLI_ghash_lookup(visithash, l->e));
 		if (i == 0) {
 			continue;
@@ -1805,9 +1810,7 @@
 		 * towards vertex v, and another for the loop heading out from
 		 * vertex v. Only need to swap the vertex on one of those times,
 		 * on the outgoing loop. */
-		if (l->v == v) {
-			l->v = verts[i];
-		}
+		l->v = verts[i];
 	}
 
 	BM_ITER(e, &eiter, bm, BM_EDGES_OF_VERT, v) {
@@ -1823,7 +1826,6 @@
 	}
 
 	BLI_ghash_free(visithash, NULL, NULL);
-	BLI_array_free(stack);
 
 	for (i = 0; i < maxindex; i++) {
 		BM_CHECK_ELEMENT(bm, verts[i]);




More information about the Bf-blender-cvs mailing list