diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-01-23 17:51:44 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-01-23 17:51:44 +0400 |
commit | 41c0f0c733fa111850da6a772dabb6115808c7b7 (patch) | |
tree | 0754c79f41813138641a640210dbe20658eee0a4 /source/blender | |
parent | 001a15a721aed6dc7d84de64288f566f08820932 (diff) |
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.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/modifiers_bmesh.c | 7 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/subsurf_ccg.c | 11 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_construct.c | 5 | ||||
-rw-r--r-- | source/blender/editors/mesh/loopcut.c | 6 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_draw.c | 10 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_ops.c | 16 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_unwrap_ops.c | 6 |
8 files changed, 32 insertions, 33 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 6a98ab324cb..67a4d6657c9 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1112,8 +1112,8 @@ void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag, 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]); } diff --git a/source/blender/blenkernel/intern/modifiers_bmesh.c b/source/blender/blenkernel/intern/modifiers_bmesh.c index 3d1349f09ed..c54a622be7e 100644 --- a/source/blender/blenkernel/intern/modifiers_bmesh.c +++ b/source/blender/blenkernel/intern/modifiers_bmesh.c @@ -171,10 +171,11 @@ BMEditMesh *CDDM_To_BMesh(Object *ob, DerivedMesh *dm, BMEditMesh *existing, int 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]; diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 76077fe3a14..f8fec9911fb 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -3040,17 +3040,16 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, /* 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)); } diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index 20003942023..821e9393fde 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -528,10 +528,11 @@ BMesh *BM_Copy_Mesh(BMesh *bmold) 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)]; } diff --git a/source/blender/editors/mesh/loopcut.c b/source/blender/editors/mesh/loopcut.c index 62711249a4f..1aee1e9a19b 100644 --- a/source/blender/editors/mesh/loopcut.c +++ b/source/blender/editors/mesh/loopcut.c @@ -239,10 +239,10 @@ static void edgering_sel(tringselOpData *lcd, int previewlines, int select) 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++; } } diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index 77609b9618b..9e2a2abe837 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -187,12 +187,12 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe 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 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe 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]; diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index fd868f1c935..090752d7b02 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -1953,9 +1953,9 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) } /* 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 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) } /* 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 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) 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++; diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 3377fdad9db..11ea0f12a9e 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -1409,16 +1409,14 @@ static void uv_map_mirror(BMEditMesh *em, BMFace *efa, MTexPoly *UNUSED(tf)) 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 @@ static void uv_map_mirror(BMEditMesh *em, BMFace *efa, MTexPoly *UNUSED(tf)) } } - BLI_array_free(uvs); + BLI_array_fixedstack_free(uvs); } static int sphere_project_exec(bContext *C, wmOperator *op) |