[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43630] branches/bmesh/blender/source/ blender/editors/transform/transform_conversions.c: avoid using resizing array for transform (size is known to begin with, use single alloc)

Campbell Barton ideasman42 at gmail.com
Mon Jan 23 14:15:52 CET 2012


Revision: 43630
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43630
Author:   campbellbarton
Date:     2012-01-23 13:15:40 +0000 (Mon, 23 Jan 2012)
Log Message:
-----------
avoid using resizing array for transform (size is known to begin with, use single alloc)

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/editors/transform/transform_conversions.c

Modified: branches/bmesh/blender/source/blender/editors/transform/transform_conversions.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/transform/transform_conversions.c	2012-01-23 08:48:52 UTC (rev 43629)
+++ branches/bmesh/blender/source/blender/editors/transform/transform_conversions.c	2012-01-23 13:15:40 UTC (rev 43630)
@@ -2026,10 +2026,10 @@
 	float *mappedcos = NULL, *quats= NULL;
 	float mtx[3][3], smtx[3][3], (*defmats)[3][3] = NULL, (*defcos)[3] = NULL;
 	float *dists=NULL;
-	int count=0, countsel=0, a, totleft, *selstate = NULL;
-	BLI_array_declare(selstate);
+	int count=0, countsel=0, a, totleft;
 	int propmode = (t->flag & T_PROP_EDIT) ? (t->flag & (T_PROP_EDIT | T_PROP_CONNECTED)) : 0;
 	int mirror = 0;
+	char *selstate = NULL;
 	short selectmode = ts->selectmode;
 
 	if (t->flag & T_MIRROR)
@@ -2091,12 +2091,11 @@
 	}
 
 	/* now we can count. we store selection state in selstate, since
-	   get_crazy_mapped_editverts messes up the index state of the
-	   verts*/
+	 * get_crazy_mapped_editverts messes up the index state of the
+	 * verts*/
+	selstate = MEM_callocN(sizeof(*selstate) * bm->totvert, __func__);
 	eve = BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL);
 	for(a=0; eve; eve=BMIter_Step(&iter), a++) {
-		BLI_array_growone(selstate);
-
 		if (BM_TestHFlag(eve, BM_TMP_TAG)) {
 			selstate[a] = 1;
 			countsel++;
@@ -2257,7 +2256,7 @@
 	if (dists)
 		MEM_freeN(dists);
 	
-	BLI_array_free(selstate);
+	MEM_freeN(selstate);
 
 	if (t->flag & T_MIRROR) {
 		EDBM_EndMirrorCache(em);



More information about the Bf-blender-cvs mailing list