From ccdacf1c9b31b15e188aa9e9adb044ffd0ca0da4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 15 Feb 2018 23:36:11 +1100 Subject: Cleanup: use '_len' instead of '_size' w/ BLI API - When returning the number of items in a collection use BLI_*_len() - Keep _size() for size in bytes. - Keep _count() for data structures that don't store length (hint this isn't a simple getter). See P611 to apply instead of manually resolving conflicts. --- source/blender/editors/armature/editarmature_sketch.c | 2 +- source/blender/editors/armature/reeb.c | 10 +++++----- source/blender/editors/curve/editcurve.c | 2 +- source/blender/editors/curve/editcurve_paint.c | 12 ++++++------ source/blender/editors/curve/editcurve_select.c | 2 +- source/blender/editors/mesh/editmesh_knife.c | 2 +- source/blender/editors/sculpt_paint/sculpt_uv.c | 4 ++-- source/blender/editors/space_outliner/outliner_tree.c | 6 +++--- source/blender/editors/uvedit/uvedit_parametrizer.c | 4 ++-- source/blender/editors/uvedit/uvedit_smart_stitch.c | 2 +- 10 files changed, 23 insertions(+), 23 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index bba486bc65c..86d5f75888d 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -172,7 +172,7 @@ const char *BIF_listTemplates(const bContext *UNUSED(C)) GHashIterator ghi; const char *menu_header = IFACE_("Template %t|None %x0|"); char *p; - const size_t template_size = (BLI_ghash_size(TEMPLATES_HASH) * 32 + 30); + const size_t template_size = (BLI_ghash_len(TEMPLATES_HASH) * 32 + 30); if (TEMPLATES_MENU != NULL) { MEM_freeN(TEMPLATES_MENU); diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c index 2bcf3099104..63a255806b8 100644 --- a/source/blender/editors/armature/reeb.c +++ b/source/blender/editors/armature/reeb.c @@ -546,7 +546,7 @@ void verifyFaces(ReebGraph *rg) int total = 0; ReebArc *arc = NULL; for (arc = rg->arcs.first; arc; arc = arc->next) { - total += BLI_ghash_size(arc->faces); + total += BLI_ghash_len(arc->faces); } #endif @@ -1656,7 +1656,7 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold)) { GHashIterator ghi; int merging = 0; - int total = BLI_ghash_size(arc->faces); + int total = BLI_ghash_len(arc->faces); float avg_angle = 0; float avg_vec[3] = {0, 0, 0}; @@ -1932,7 +1932,7 @@ void REEB_exportGraph(ReebGraph *rg, int count) add_v3_v3v3(p, arc->tail->p, arc->head->p); mul_v3_fl(p, 0.5f); - fprintf(f, "angle %0.3f %0.3f %0.3f %0.3f %i\n", p[0], p[1], p[2], arc->angle, BLI_ghash_size(arc->faces)); + fprintf(f, "angle %0.3f %0.3f %0.3f %0.3f %i\n", p[0], p[1], p[2], arc->angle, BLI_ghash_len(arc->faces)); exportNode(f, "v2", arc->tail); } @@ -2678,7 +2678,7 @@ static void shortestPathsFromVert(EditMesh *em, EditVert *starting_vert, EdgeInd eed->f1 = 0; } - while (BLI_heap_size(edge_heap) > 0) { + while (BLI_heap_len(edge_heap) > 0) { float current_weight; current_eve->f1 = 1; /* mark vertex as selected */ @@ -2695,7 +2695,7 @@ static void shortestPathsFromVert(EditMesh *em, EditVert *starting_vert, EdgeInd /* Find next shortest edge with unselected verts */ do { current_weight = BLI_heap_node_value(BLI_heap_top(edge_heap)); - select_eed = BLI_heap_popmin(edge_heap); + select_eed = BLI_heap_pop_min(edge_heap); } while (select_eed != NULL && select_eed->v1->f1 != 0 && select_eed->v2->f1); if (select_eed != NULL) { diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index f4ee05636c7..6e059342a6b 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -527,7 +527,7 @@ static GHash *dupli_keyIndexHash(GHash *keyindex) GHash *gh; GHashIterator gh_iter; - gh = BLI_ghash_ptr_new_ex("dupli_keyIndex gh", BLI_ghash_size(keyindex)); + gh = BLI_ghash_ptr_new_ex("dupli_keyIndex gh", BLI_ghash_len(keyindex)); GHASH_ITER (gh_iter, keyindex) { void *cv = BLI_ghashIterator_getKey(&gh_iter); diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c index 4602945d11c..5bba21f6252 100644 --- a/source/blender/editors/curve/editcurve_paint.c +++ b/source/blender/editors/curve/editcurve_paint.c @@ -359,7 +359,7 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS wmOperator *op = arg; struct CurveDrawData *cdd = op->customdata; - const int stroke_len = BLI_mempool_count(cdd->stroke_elem_pool); + const int stroke_len = BLI_mempool_len(cdd->stroke_elem_pool); if (stroke_len == 0) { return; @@ -677,7 +677,7 @@ static void curve_draw_exec_precalc(wmOperator *op) if (!RNA_property_is_set(op->ptr, prop)) { bool use_cyclic = false; - if (BLI_mempool_count(cdd->stroke_elem_pool) > 2) { + if (BLI_mempool_len(cdd->stroke_elem_pool) > 2) { BLI_mempool_iter iter; const struct StrokeElem *selem, *selem_first, *selem_last; @@ -703,7 +703,7 @@ static void curve_draw_exec_precalc(wmOperator *op) (cps->radius_taper_end != 0.0f)) { /* note, we could try to de-duplicate the length calculations above */ - const int stroke_len = BLI_mempool_count(cdd->stroke_elem_pool); + const int stroke_len = BLI_mempool_len(cdd->stroke_elem_pool); BLI_mempool_iter iter; struct StrokeElem *selem, *selem_prev; @@ -763,14 +763,14 @@ static int curve_draw_exec(bContext *C, wmOperator *op) Curve *cu = obedit->data; ListBase *nurblist = object_editcurve_get(obedit); - int stroke_len = BLI_mempool_count(cdd->stroke_elem_pool); + int stroke_len = BLI_mempool_len(cdd->stroke_elem_pool); const bool is_3d = (cu->flag & CU_3D) != 0; invert_m4_m4(obedit->imat, obedit->obmat); - if (BLI_mempool_count(cdd->stroke_elem_pool) == 0) { + if (BLI_mempool_len(cdd->stroke_elem_pool) == 0) { curve_draw_stroke_from_operator(op); - stroke_len = BLI_mempool_count(cdd->stroke_elem_pool); + stroke_len = BLI_mempool_len(cdd->stroke_elem_pool); } ED_curve_deselect_all(cu->editnurb); diff --git a/source/blender/editors/curve/editcurve_select.c b/source/blender/editors/curve/editcurve_select.c index 02b8970731c..4a4b13d0d1b 100644 --- a/source/blender/editors/curve/editcurve_select.c +++ b/source/blender/editors/curve/editcurve_select.c @@ -1607,7 +1607,7 @@ static void curve_select_shortest_path_surf(Nurb *nu, int vert_src, int vert_dst int axis, sign; int u, v; - vert_curr = *((int *)BLI_heap_popmin(heap)); + vert_curr = *((int *)BLI_heap_pop_min(heap)); if (vert_curr == vert_dst) { break; } diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 658f8b3958b..76a0d874a0b 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -2284,7 +2284,7 @@ static void knife_make_face_cuts(KnifeTool_OpData *kcd, BMFace *f, ListBase *kfe /* point to knife edges we've created edges in, edge_array aligned */ KnifeEdge **kfe_array = BLI_array_alloca(kfe_array, edge_array_len); - BLI_assert(BLI_gset_size(kcd->edgenet.edge_visit) == 0); + BLI_assert(BLI_gset_len(kcd->edgenet.edge_visit) == 0); i = 0; for (ref = kfedges->first; ref; ref = ref->next) { diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index abc4b28ee50..5ef9d4a6499 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -759,7 +759,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm MEM_freeN(uniqueUv); /* Allocate connectivity data, we allocate edges once */ - data->uvedges = MEM_mallocN(sizeof(*data->uvedges) * BLI_ghash_size(edgeHash), "uv_brush_edge_connectivity_data"); + data->uvedges = MEM_mallocN(sizeof(*data->uvedges) * BLI_ghash_len(edgeHash), "uv_brush_edge_connectivity_data"); if (!data->uvedges) { BLI_ghash_free(edgeHash, NULL, NULL); MEM_freeN(edges); @@ -772,7 +772,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm GHASH_ITER (gh_iter, edgeHash) { data->uvedges[i++] = *((UvEdge *)BLI_ghashIterator_getKey(&gh_iter)); } - data->totalUvEdges = BLI_ghash_size(edgeHash); + data->totalUvEdges = BLI_ghash_len(edgeHash); /* cleanup temporary stuff */ BLI_ghash_free(edgeHash, NULL, NULL); diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index cf77afa32c4..051605b1079 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -113,7 +113,7 @@ static void outliner_storage_cleanup(SpaceOops *soops) } if (unused) { - if (BLI_mempool_count(ts) == unused) { + if (BLI_mempool_len(ts) == unused) { BLI_mempool_destroy(ts); soops->treestore = NULL; if (soops->treehash) { @@ -123,7 +123,7 @@ static void outliner_storage_cleanup(SpaceOops *soops) } else { TreeStoreElem *tsenew; - BLI_mempool *new_ts = BLI_mempool_create(sizeof(TreeStoreElem), BLI_mempool_count(ts) - unused, + BLI_mempool *new_ts = BLI_mempool_create(sizeof(TreeStoreElem), BLI_mempool_len(ts) - unused, 512, BLI_MEMPOOL_ALLOW_ITER); BLI_mempool_iternew(ts, &iter); while ((tselem = BLI_mempool_iterstep(&iter))) { @@ -1635,7 +1635,7 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) Base *base; TreeElement *te = NULL, *ten; TreeStoreElem *tselem; - int show_opened = !soops->treestore || !BLI_mempool_count(soops->treestore); /* on first view, we open scenes */ + int show_opened = !soops->treestore || !BLI_mempool_len(soops->treestore); /* on first view, we open scenes */ /* Are we looking for something - we want to tag parents to filter child matches * - NOT in datablocks view - searching all datablocks takes way too long to be useful diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 2a3a2b84223..f8a93bd2ce3 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -1291,7 +1291,7 @@ static void p_chart_fill_boundary(PChart *chart, PEdge *be, int nedges) while (nedges > 2) { PEdge *ne, *ne1, *ne2; - e = (PEdge *)BLI_heap_popmin(heap); + e = (PEdge *)BLI_heap_pop_min(heap); e1 = p_boundary_edge_prev(e); e2 = p_boundary_edge_next(e); @@ -2190,7 +2190,7 @@ static void p_chart_simplify_compute(PChart *chart) break; HeapNode *link = BLI_heap_top(heap); - PEdge *edge = (PEdge *)BLI_heap_popmin(heap), *pair = edge->pair; + PEdge *edge = (PEdge *)BLI_heap_pop_min(heap), *pair = edge->pair; PVert *oldv, *keepv; PEdge *wheele, *nexte; diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index c2a38a90621..da36170310a 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -1782,7 +1782,7 @@ static int stitch_init(bContext *C, wmOperator *op) } } - total_edges = BLI_ghash_size(edge_hash); + total_edges = BLI_ghash_len(edge_hash); state->edges = edges = MEM_mallocN(sizeof(*edges) * total_edges, "stitch_edges"); /* I assume any system will be able to at least allocate an iterator :p */ -- cgit v1.2.3