[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43637] branches/bmesh/blender/source/ blender: replace BLI_array_growone() with BLI_array_growitems() when the size of the increase is known ahead of time, will reduce reallocs and give some speedup.
Campbell Barton
ideasman42 at gmail.com
Mon Jan 23 14:51:45 CET 2012
Revision: 43637
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43637
Author: campbellbarton
Date: 2012-01-23 13:51:44 +0000 (Mon, 23 Jan 2012)
Log Message:
-----------
replace BLI_array_growone() with BLI_array_growitems() when the size of the increase is known ahead of time, will reduce reallocs and give some speedup.
Modified Paths:
--------------
branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c
branches/bmesh/blender/source/blender/blenkernel/intern/modifiers_bmesh.c
branches/bmesh/blender/source/blender/blenkernel/intern/subsurf_ccg.c
branches/bmesh/blender/source/blender/bmesh/intern/bmesh_construct.c
branches/bmesh/blender/source/blender/editors/mesh/loopcut.c
branches/bmesh/blender/source/blender/editors/uvedit/uvedit_draw.c
branches/bmesh/blender/source/blender/editors/uvedit/uvedit_ops.c
branches/bmesh/blender/source/blender/editors/uvedit/uvedit_unwrap_ops.c
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c 2012-01-23 13:50:00 UTC (rev 43636)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c 2012-01-23 13:51:44 UTC (rev 43637)
@@ -1112,8 +1112,8 @@
for (i=0; i<dm->numPolyData; i++, mp++) {
ml = mloop + mp->loopstart;
- for (j=0; j<mp->totloop; j++, ml++, totloop++) {
- BLI_array_growone(wtcol_l);
+ BLI_array_growitems(wtcol_l, mp->totloop);
+ for (j = 0; j < mp->totloop; j++, ml++, totloop++) {
copy_v4_v4_char((char *)&wtcol_l[totloop],
(char *)&wtcol_v[4 * ml->v]);
}
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/modifiers_bmesh.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/modifiers_bmesh.c 2012-01-23 13:50:00 UTC (rev 43636)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/modifiers_bmesh.c 2012-01-23 13:51:44 UTC (rev 43637)
@@ -171,10 +171,11 @@
BLI_array_empty(verts);
BLI_array_empty(edges);
+ BLI_array_growitems(verts, mp->totloop);
+ BLI_array_growitems(edges, mp->totloop);
+
ml = mloop + mp->loopstart;
- for (j=0; j<mp->totloop; j++, ml++) {
- BLI_array_growone(verts);
- BLI_array_growone(edges);
+ for (j = 0; j < mp->totloop; j++, ml++) {
verts[j] = vtable[ml->v];
edges[j] = etable[ml->e];
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/subsurf_ccg.c 2012-01-23 13:50:00 UTC (rev 43636)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/subsurf_ccg.c 2012-01-23 13:51:44 UTC (rev 43637)
@@ -3040,17 +3040,16 @@
/* set the face base vert */
*((int*)ccgSubSurf_getFaceUserData(ss, f)) = vertNum;
- BLI_array_empty(loopidx);
- for (s=0; s<numVerts; s++) {
- BLI_array_growone(loopidx);
+ BLI_array_empty(loopidx);
+ BLI_array_growitems(loopidx, numVerts);
+ for (s = 0; s < numVerts; s++) {
loopidx[s] = loopindex++;
}
BLI_array_empty(vertidx);
- for(s = 0; s < numVerts; s++) {
+ BLI_array_growitems(vertidx, numVerts);
+ for (s = 0; s < numVerts; s++) {
CCGVert *v = ccgSubSurf_getFaceVert(ss, f, s);
-
- BLI_array_growone(vertidx);
vertidx[s] = GET_INT_FROM_POINTER(ccgSubSurf_getVertVertHandle(v));
}
Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_construct.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_construct.c 2012-01-23 13:50:00 UTC (rev 43636)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_construct.c 2012-01-23 13:51:44 UTC (rev 43637)
@@ -528,10 +528,11 @@
BLI_array_empty(loops);
BLI_array_empty(edges);
+ BLI_array_growitems(loops, f->len);
+ BLI_array_growitems(edges, f->len);
+
l = BMIter_New(&liter, bmold, BM_LOOPS_OF_FACE, f);
for (j=0; j<f->len; j++, l = BMIter_Step(&liter)) {
- BLI_array_growone(loops);
- BLI_array_growone(edges);
loops[j] = l;
edges[j] = etable[BM_GetIndex(l->e)];
}
Modified: branches/bmesh/blender/source/blender/editors/mesh/loopcut.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/loopcut.c 2012-01-23 13:50:00 UTC (rev 43636)
+++ branches/bmesh/blender/source/blender/editors/mesh/loopcut.c 2012-01-23 13:51:44 UTC (rev 43637)
@@ -239,10 +239,10 @@
co[1][0] = (v[1][1]->co[0] - v[1][0]->co[0])*(i/((float)previewlines+1))+v[1][0]->co[0];
co[1][1] = (v[1][1]->co[1] - v[1][0]->co[1])*(i/((float)previewlines+1))+v[1][0]->co[1];
co[1][2] = (v[1][1]->co[2] - v[1][0]->co[2])*(i/((float)previewlines+1))+v[1][0]->co[2];
-
+
BLI_array_growone(edges);
- VECCOPY(edges[tot][0], co[0]);
- VECCOPY(edges[tot][1], co[1]);
+ copy_v3_v3(edges[tot][0], co[0]);
+ copy_v3_v3(edges[tot][1], co[1]);
tot++;
}
}
Modified: branches/bmesh/blender/source/blender/editors/uvedit/uvedit_draw.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/uvedit/uvedit_draw.c 2012-01-23 13:50:00 UTC (rev 43636)
+++ branches/bmesh/blender/source/blender/editors/uvedit/uvedit_draw.c 2012-01-23 13:51:44 UTC (rev 43637)
@@ -187,12 +187,12 @@
BLI_array_empty(tf_uv);
BLI_array_empty(tf_uvorig);
-
+ BLI_array_growitems(tf_uv, efa->len);
+ BLI_array_growitems(tf_uvorig, efa->len);
+
i = 0;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
luv= CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
- BLI_array_growone(tf_uv);
- BLI_array_growone(tf_uvorig);
tf_uvorig[i][0] = luv->uv[0];
tf_uvorig[i][1] = luv->uv[1];
@@ -238,12 +238,12 @@
BLI_array_empty(tf_uv);
BLI_array_empty(tf_uvorig);
+ BLI_array_growitems(tf_uv, efa->len);
+ BLI_array_growitems(tf_uvorig, efa->len);
i = 0;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
luv= CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
- BLI_array_growone(tf_uv);
- BLI_array_growone(tf_uvorig);
tf_uvorig[i][0] = luv->uv[0];
tf_uvorig[i][1] = luv->uv[1];
Modified: branches/bmesh/blender/source/blender/editors/uvedit/uvedit_ops.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/uvedit/uvedit_ops.c 2012-01-23 13:50:00 UTC (rev 43636)
+++ branches/bmesh/blender/source/blender/editors/uvedit/uvedit_ops.c 2012-01-23 13:51:44 UTC (rev 43637)
@@ -1953,9 +1953,9 @@
}
/* mark 1 vertex as being hit */
+ BLI_array_growitems(hitv, hit.efa->len);
+ BLI_array_growitems(hituv, hit.efa->len);
for(i=0; i<hit.efa->len; i++) {
- BLI_array_growone(hitv);
- BLI_array_growone(hituv);
hitv[i]= 0xFFFFFFFF;
}
@@ -1974,9 +1974,9 @@
}
/* mark 2 edge vertices as being hit */
- for(i=0; i<hit.efa->len; i++) {
- BLI_array_growone(hitv);
- BLI_array_growone(hituv);
+ BLI_array_growitems(hitv, hit.efa->len);
+ BLI_array_growitems(hituv, hit.efa->len);
+ for (i=0; i < hit.efa->len; i++) {
hitv[i]= 0xFFFFFFFF;
}
@@ -2002,12 +2002,12 @@
BM_set_actFace(em->bm, hit.efa);
/* mark all face vertices as being hit */
+
+ BLI_array_growitems(hitv, hit.efa->len);
+ BLI_array_growitems(hituv, hit.efa->len);
i = 0;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, hit.efa) {
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
-
- BLI_array_growone(hitv);
- BLI_array_growone(hituv);
hituv[i]= luv->uv;
hitv[i] = BM_GetIndex(l->v);
i++;
Modified: branches/bmesh/blender/source/blender/editors/uvedit/uvedit_unwrap_ops.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/uvedit/uvedit_unwrap_ops.c 2012-01-23 13:50:00 UTC (rev 43636)
+++ branches/bmesh/blender/source/blender/editors/uvedit/uvedit_unwrap_ops.c 2012-01-23 13:51:44 UTC (rev 43637)
@@ -1409,16 +1409,14 @@
BMLoop *l;
BMIter liter;
MLoopUV *luv;
- BLI_array_declare(uvs);
float **uvs = NULL;
+ BLI_array_fixedstack_declare(uvs, BM_NGON_STACK_SIZE, efa->len, __func__);
float dx;
int i, mi;
i = 0;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
- BLI_array_growone(uvs);
-
uvs[i] = luv->uv;
i++;
}
@@ -1435,7 +1433,7 @@
}
}
- BLI_array_free(uvs);
+ BLI_array_fixedstack_free(uvs);
}
static int sphere_project_exec(bContext *C, wmOperator *op)
More information about the Bf-blender-cvs
mailing list