[Bf-blender-cvs] [3382b07ad6c] master: Cleanup: rename 'count' to 'len'

Campbell Barton noreply at git.blender.org
Tue Jul 6 04:10:37 CEST 2021


Commit: 3382b07ad6cfbb117cf8ec8fc95aa46cf585237e
Author: Campbell Barton
Date:   Tue Jul 6 12:05:27 2021 +1000
Branches: master
https://developer.blender.org/rB3382b07ad6cfbb117cf8ec8fc95aa46cf585237e

Cleanup: rename 'count' to 'len'

Reserve the term count for values that require calculation
(typically linked lists).

===================================================================

M	source/blender/bmesh/intern/bmesh_iterators.c
M	source/blender/bmesh/intern/bmesh_operator_api.h
M	source/blender/bmesh/intern/bmesh_operators.c
M	source/blender/bmesh/operators/bmo_beautify.c
M	source/blender/bmesh/operators/bmo_bisect_plane.c
M	source/blender/bmesh/operators/bmo_create.c
M	source/blender/bmesh/operators/bmo_edgenet.c
M	source/blender/bmesh/operators/bmo_extrude.c
M	source/blender/bmesh/operators/bmo_fill_attribute.c
M	source/blender/bmesh/operators/bmo_fill_edgeloop.c
M	source/blender/bmesh/operators/bmo_fill_holes.c
M	source/blender/bmesh/operators/bmo_offset_edgeloops.c
M	source/blender/bmesh/operators/bmo_planar_faces.c
M	source/blender/bmesh/operators/bmo_rotate_edges.c
M	source/blender/bmesh/operators/bmo_triangulate.c
M	source/blender/bmesh/operators/bmo_utils.c
M	source/blender/editors/mesh/editmesh_tools.c

===================================================================

diff --git a/source/blender/bmesh/intern/bmesh_iterators.c b/source/blender/bmesh/intern/bmesh_iterators.c
index ff6274cff12..bd28022de4b 100644
--- a/source/blender/bmesh/intern/bmesh_iterators.c
+++ b/source/blender/bmesh/intern/bmesh_iterators.c
@@ -221,21 +221,21 @@ void *BMO_iter_as_arrayN(BMOpSlot slot_args[BMO_OP_MAX_SLOTS],
 {
   BMOIter iter;
   BMElem *ele;
-  int count = BMO_slot_buffer_count(slot_args, slot_name);
+  const int slot_len = BMO_slot_buffer_len(slot_args, slot_name);
 
   BLI_assert(stack_array_size == 0 || (stack_array_size && stack_array));
 
-  if ((ele = BMO_iter_new(&iter, slot_args, slot_name, restrictmask)) && count > 0) {
-    BMElem **array = count > stack_array_size ? MEM_mallocN(sizeof(ele) * count, __func__) :
-                                                stack_array;
+  if ((ele = BMO_iter_new(&iter, slot_args, slot_name, restrictmask)) && slot_len > 0) {
+    BMElem **array = slot_len > stack_array_size ? MEM_mallocN(sizeof(ele) * slot_len, __func__) :
+                                                   stack_array;
     int i = 0;
 
     do {
       array[i++] = ele;
     } while ((ele = BMO_iter_step(&iter)));
-    BLI_assert(i <= count);
+    BLI_assert(i <= slot_len);
 
-    if (i != count) {
+    if (i != slot_len) {
       if ((void **)array != stack_array) {
         array = MEM_reallocN(array, sizeof(ele) * i);
       }
diff --git a/source/blender/bmesh/intern/bmesh_operator_api.h b/source/blender/bmesh/intern/bmesh_operator_api.h
index 767c455e5e9..0f9488bd091 100644
--- a/source/blender/bmesh/intern/bmesh_operator_api.h
+++ b/source/blender/bmesh/intern/bmesh_operator_api.h
@@ -565,8 +565,8 @@ void BMO_slot_buffer_from_single(BMOperator *op, BMOpSlot *slot, BMHeader *ele);
 void *BMO_slot_buffer_get_single(BMOpSlot *slot);
 
 /* counts number of elements inside a slot array. */
-int BMO_slot_buffer_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name);
-int BMO_slot_map_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name);
+int BMO_slot_buffer_len(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name);
+int BMO_slot_map_len(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name);
 
 void BMO_slot_map_insert(BMOperator *op, BMOpSlot *slot, const void *element, const void *data);
 
diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c
index 4a611d78d58..cf7697ad35f 100644
--- a/source/blender/bmesh/intern/bmesh_operators.c
+++ b/source/blender/bmesh/intern/bmesh_operators.c
@@ -678,7 +678,7 @@ void BMO_mesh_selected_remap(BMesh *bm,
   }
 }
 
-int BMO_slot_buffer_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
+int BMO_slot_buffer_len(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
 {
   BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
   BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF);
@@ -691,7 +691,7 @@ int BMO_slot_buffer_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot
   return slot->len;
 }
 
-int BMO_slot_map_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
+int BMO_slot_map_len(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
 {
   BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
   BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING);
diff --git a/source/blender/bmesh/operators/bmo_beautify.c b/source/blender/bmesh/operators/bmo_beautify.c
index de26ca5ebd2..a72ff6363ed 100644
--- a/source/blender/bmesh/operators/bmo_beautify.c
+++ b/source/blender/bmesh/operators/bmo_beautify.c
@@ -59,7 +59,7 @@ void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op)
 
   /* will over alloc if some edges can't be rotated */
   edge_array = MEM_mallocN(
-      sizeof(*edge_array) * (size_t)BMO_slot_buffer_count(op->slots_in, "edges"), __func__);
+      sizeof(*edge_array) * (size_t)BMO_slot_buffer_len(op->slots_in, "edges"), __func__);
 
   BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
 
diff --git a/source/blender/bmesh/operators/bmo_bisect_plane.c b/source/blender/bmesh/operators/bmo_bisect_plane.c
index 55b6337bea4..6296694f121 100644
--- a/source/blender/bmesh/operators/bmo_bisect_plane.c
+++ b/source/blender/bmesh/operators/bmo_bisect_plane.c
@@ -68,7 +68,7 @@ void bmo_bisect_plane_exec(BMesh *bm, BMOperator *op)
     /* Use an array of vertices because 'geom' contains both verts and edges that may use them.
      * Removing a vert may remove and edge which is later checked by #BMO_ITER.
      * over-allocate the total possible vert count. */
-    const int vert_arr_max = min_ii(bm->totvert, BMO_slot_buffer_count(op->slots_in, "geom"));
+    const int vert_arr_max = min_ii(bm->totvert, BMO_slot_buffer_len(op->slots_in, "geom"));
     BMVert **vert_arr = MEM_mallocN(sizeof(*vert_arr) * (size_t)vert_arr_max, __func__);
     BMOIter siter;
     BMVert *v;
diff --git a/source/blender/bmesh/operators/bmo_create.c b/source/blender/bmesh/operators/bmo_create.c
index 2e2a7e0964e..a740e4d66e8 100644
--- a/source/blender/bmesh/operators/bmo_create.c
+++ b/source/blender/bmesh/operators/bmo_create.c
@@ -172,7 +172,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
     BMO_op_exec(bm, &op_sub);
 
     /* return if edge net create did something */
-    if (BMO_slot_buffer_count(op_sub.slots_out, "faces.out")) {
+    if (BMO_slot_buffer_len(op_sub.slots_out, "faces.out")) {
       BMO_slot_copy(&op_sub, slots_out, "faces.out", op, slots_out, "faces.out");
       BMO_op_finish(bm, &op_sub);
       return;
@@ -191,7 +191,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
     BMO_op_exec(bm, &op_sub);
 
     /* if we dissolved anything, then return */
-    if (BMO_slot_buffer_count(op_sub.slots_out, "region.out")) {
+    if (BMO_slot_buffer_len(op_sub.slots_out, "region.out")) {
       BMO_slot_copy(&op_sub, slots_out, "region.out", op, slots_out, "faces.out");
       BMO_op_finish(bm, &op_sub);
       return;
@@ -211,7 +211,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
     BMO_op_exec(bm, &op_sub);
 
     /* return if edge loop fill did something */
-    if (BMO_slot_buffer_count(op_sub.slots_out, "faces.out")) {
+    if (BMO_slot_buffer_len(op_sub.slots_out, "faces.out")) {
       BMO_slot_copy(&op_sub, slots_out, "faces.out", op, slots_out, "faces.out");
       BMO_op_finish(bm, &op_sub);
       return;
diff --git a/source/blender/bmesh/operators/bmo_edgenet.c b/source/blender/bmesh/operators/bmo_edgenet.c
index 5449762b83c..8e4b0732feb 100644
--- a/source/blender/bmesh/operators/bmo_edgenet.c
+++ b/source/blender/bmesh/operators/bmo_edgenet.c
@@ -79,7 +79,7 @@ void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op)
   BMO_op_exec(bm, &op_attr);
 
   /* check if some faces couldn't be touched */
-  if (BMO_slot_buffer_count(op_attr.slots_out, "faces_fail.out")) {
+  if (BMO_slot_buffer_len(op_attr.slots_out, "faces_fail.out")) {
     BMO_op_callf(bm, op->flag, "recalc_face_normals faces=%S", &op_attr, "faces_fail.out");
   }
   BMO_op_finish(bm, &op_attr);
diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c
index ffdce943d9f..0cedc2324f2 100644
--- a/source/blender/bmesh/operators/bmo_extrude.c
+++ b/source/blender/bmesh/operators/bmo_extrude.c
@@ -459,7 +459,7 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
     }
 
     /* Allocate array to store possible vertices that will be dissolved. */
-    int boundary_edges_len = BMO_slot_map_count(dupeop.slots_out, "boundary_map.out");
+    int boundary_edges_len = BMO_slot_map_len(dupeop.slots_out, "boundary_map.out");
     /* We do not know the real number of boundary vertices. */
     int boundary_verts_len_maybe = 2 * boundary_edges_len;
     dissolve_verts = MEM_mallocN(boundary_verts_len_maybe * sizeof(*dissolve_verts), __func__);
diff --git a/source/blender/bmesh/operators/bmo_fill_attribute.c b/source/blender/bmesh/operators/bmo_fill_attribute.c
index e377fa6079b..5e8924c4a3b 100644
--- a/source/blender/bmesh/operators/bmo_fill_attribute.c
+++ b/source/blender/bmesh/operators/bmo_fill_attribute.c
@@ -161,7 +161,7 @@ void bmo_face_attribute_fill_exec(BMesh *bm, BMOperator *op)
   /* now we can copy adjacent data */
   face_tot = bmesh_face_attribute_fill(bm, use_normals, use_data);
 
-  if (face_tot != BMO_slot_buffer_count(op->slots_in, "faces")) {
+  if (face_tot != BMO_slot_buffer_len(op->slots_in, "faces")) {
     /* any remaining tags will be skipped */
     BMO_slot_buffer_from_enabled_hflag(
         bm, op, op->slots_out, "faces_fail.out", BM_FACE, BM_ELEM_TAG);
diff --git a/source/blender/bmesh/operators/bmo_fill_edgeloop.c b/source/blender/bmesh/operators/bmo_fill_edgeloop.c
index 2b481542463..da4567d947b 100644
--- a/source/blender/bmesh/operators/bmo_fill_edgeloop.c
+++ b/source/blender/bmesh/operators/bmo_fill_edgeloop.c
@@ -35,7 +35,7 @@
 void bmo_edgeloop_fill_exec(BMesh *bm, BMOperator *op)
 {
   /* first collect an array of unique from the edges */
-  const int tote = BMO_slot_buffer_count(op->slots_in, "edges");
+  const int tote = BMO_slot_buffer_len(op->slots_in, "edges");
   const int totv = tote; /* these should be the same */
   BMVert **verts = MEM_mallocN(sizeof(*verts) * totv, __func__);
 
diff --git a/source/blender/bmesh/operators/bmo_fill_holes.c b/source/blender/bmesh/operators/bmo_fill_holes.c
index 64107fefe73..a24d81c5bdb 100644
--- a/source/blender/bmesh/operators/bmo_fill_holes.c
+++ b/source/blender/bmesh/operators/bmo_fill_holes.c
@@ -66,7 +66,7 @@ void bmo_holes_fill_exec(BMesh *bm, BMOperator *op)
   BMO_op_exec(bm, &op_attr);
 
   /* check if some faces couldn't be touched */
-  if (BMO_slot_buffer_count(op_attr.slots_out, "faces_fail.out")) {
+  if (BMO_slot_buffer_len(op_attr.slots_out, "faces_fail.out")) {
     BMOIter siter;
     BMFace *f;
 
diff --git a/source/blender/bmesh/operators/bmo_offset_edgeloops.c b/source/blender/bmesh/operators/bmo_offset_edgeloops.c
index 98a8432cfb1..28f2c9a47aa 100644
--- a/source/blender/bmesh/operators/bmo_offset_edgeloops.c
+++ b/source/blender/bmesh/operators/bmo_offset_edgeloops.c
@@ -74,7 +74,7 @@ static BMFace *bm_face_split_walk_back(BMesh *bm, BMLoop *l_src, BMLoop **r_l)
 
 void bm

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list