[Bf-blender-cvs] [367034f2101] master: Cleanup: Editors/Space/UV-Edit, Clang-Tidy else-after-return fixes

Sybren A. Stüvel noreply at git.blender.org
Fri Jul 3 17:43:28 CEST 2020


Commit: 367034f210137754ab4f07a0e7793066d2b69e59
Author: Sybren A. Stüvel
Date:   Fri Jul 3 17:30:09 2020 +0200
Branches: master
https://developer.blender.org/rB367034f210137754ab4f07a0e7793066d2b69e59

Cleanup: Editors/Space/UV-Edit, Clang-Tidy else-after-return fixes

This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/editors/uv_edit` module.

No functional changes.

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

M	source/blender/editors/uvedit/uvedit_draw.c
M	source/blender/editors/uvedit/uvedit_ops.c
M	source/blender/editors/uvedit/uvedit_parametrizer.c
M	source/blender/editors/uvedit/uvedit_select.c
M	source/blender/editors/uvedit/uvedit_smart_stitch.c
M	source/blender/editors/uvedit/uvedit_unwrap_ops.c

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

diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index 28c55813a3b..c6b8b0cd02d 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -86,16 +86,12 @@ static int draw_uvs_face_check(const ToolSettings *ts)
     if (ts->selectmode == SCE_SELECT_FACE) {
       return 2;
     }
-    else if (ts->selectmode & SCE_SELECT_FACE) {
+    if (ts->selectmode & SCE_SELECT_FACE) {
       return 1;
     }
-    else {
-      return 0;
-    }
-  }
-  else {
-    return (ts->uv_selectmode == UV_SELECT_FACE);
+    return 0;
   }
+  return (ts->uv_selectmode == UV_SELECT_FACE);
 }
 
 /* ------------------------- */
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 652d07f02db..8d85de3b141 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -998,9 +998,7 @@ static int uv_remove_doubles_exec(bContext *C, wmOperator *op)
   if (RNA_boolean_get(op->ptr, "use_unselected")) {
     return uv_remove_doubles_to_unselected(C, op);
   }
-  else {
-    return uv_remove_doubles_to_selected(C, op);
-  }
+  return uv_remove_doubles_to_selected(C, op);
 }
 
 static void UV_OT_remove_doubles(wmOperatorType *ot)
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index da8e0efa522..921b96f6023 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -321,7 +321,7 @@ static PHashLink *phash_lookup(PHash *ph, PHashKey key)
     if (link->key == key) {
       return link;
     }
-    else if (PHASH_hash(ph, link->key) != hash) {
+    if (PHASH_hash(ph, link->key) != hash) {
       return NULL;
     }
   }
@@ -337,7 +337,7 @@ static PHashLink *phash_next(PHash *ph, PHashKey key, PHashLink *link)
     if (link->key == key) {
       return link;
     }
-    else if (PHASH_hash(ph, link->key) != hash) {
+    if (PHASH_hash(ph, link->key) != hash) {
       return NULL;
     }
   }
@@ -372,12 +372,10 @@ static float p_vec_angle(const float v1[3], const float v2[3], const float v3[3]
   if (dot <= -1.0f) {
     return (float)M_PI;
   }
-  else if (dot >= 1.0f) {
+  if (dot >= 1.0f) {
     return 0.0f;
   }
-  else {
-    return acosf(dot);
-  }
+  return acosf(dot);
 }
 
 static float p_vec2_angle(const float v1[2], const float v2[2], const float v3[2])
@@ -790,9 +788,7 @@ static PVert *p_vert_lookup(PHandle *handle, PHashKey key, const float co[3], PE
   if (v) {
     return v;
   }
-  else {
-    return p_vert_add(handle, key, co, e);
-  }
+  return p_vert_add(handle, key, co, e);
 }
 
 static PVert *p_vert_copy(PChart *chart, PVert *v)
@@ -818,7 +814,7 @@ static PEdge *p_edge_lookup(PHandle *handle, PHashKey *vkeys)
     if ((e->vert->u.key == vkeys[0]) && (e->next->vert->u.key == vkeys[1])) {
       return e;
     }
-    else if ((e->vert->u.key == vkeys[1]) && (e->next->vert->u.key == vkeys[0])) {
+    if ((e->vert->u.key == vkeys[1]) && (e->next->vert->u.key == vkeys[0])) {
       return e;
     }
 
@@ -3353,11 +3349,10 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart)
     p_chart_lscm_load_solution(chart);
     return P_TRUE;
   }
-  else {
-    for (v = chart->verts; v; v = v->nextlink) {
-      v->uv[0] = 0.0f;
-      v->uv[1] = 0.0f;
-    }
+
+  for (v = chart->verts; v; v = v->nextlink) {
+    v->uv[0] = 0.0f;
+    v->uv[1] = 0.0f;
   }
 
   return P_FALSE;
@@ -3542,20 +3537,16 @@ static int p_compare_geometric_uv(const void *a, const void *b)
   if (v1->uv[0] < v2->uv[0]) {
     return -1;
   }
-  else if (v1->uv[0] == v2->uv[0]) {
+  if (v1->uv[0] == v2->uv[0]) {
     if (v1->uv[1] < v2->uv[1]) {
       return -1;
     }
-    else if (v1->uv[1] == v2->uv[1]) {
+    if (v1->uv[1] == v2->uv[1]) {
       return 0;
     }
-    else {
-      return 1;
-    }
-  }
-  else {
     return 1;
   }
+  return 1;
 }
 
 static PBool p_chart_convex_hull(PChart *chart, PVert ***r_verts, int *r_nverts, int *r_right)
@@ -3935,14 +3926,11 @@ static PBool p_node_intersect(SmoothNode *node, float co[2])
 
     return P_FALSE;
   }
-  else {
-    if (co[node->axis] < node->split) {
-      return p_node_intersect(node->c1, co);
-    }
-    else {
-      return p_node_intersect(node->c2, co);
-    }
+
+  if (co[node->axis] < node->split) {
+    return p_node_intersect(node->c1, co);
   }
+  return p_node_intersect(node->c2, co);
 }
 
 /* smoothing */
@@ -3955,12 +3943,10 @@ static int p_compare_float(const void *a_, const void *b_)
   if (a < b) {
     return -1;
   }
-  else if (a == b) {
+  if (a == b) {
     return 0;
   }
-  else {
-    return 1;
-  }
+  return 1;
 }
 
 static float p_smooth_median_edge_length(PChart *chart)
diff --git a/source/blender/editors/uvedit/uvedit_select.c b/source/blender/editors/uvedit/uvedit_select.c
index cc9be9d48c1..b701e94cd77 100644
--- a/source/blender/editors/uvedit/uvedit_select.c
+++ b/source/blender/editors/uvedit/uvedit_select.c
@@ -119,9 +119,7 @@ bool uvedit_face_visible_test_ex(const ToolSettings *ts, BMFace *efa)
   if (ts->uv_flag & UV_SYNC_SELECTION) {
     return (BM_elem_flag_test(efa, BM_ELEM_HIDDEN) == 0);
   }
-  else {
-    return (BM_elem_flag_test(efa, BM_ELEM_HIDDEN) == 0 && BM_elem_flag_test(efa, BM_ELEM_SELECT));
-  }
+  return (BM_elem_flag_test(efa, BM_ELEM_HIDDEN) == 0 && BM_elem_flag_test(efa, BM_ELEM_SELECT));
 }
 bool uvedit_face_visible_test(const Scene *scene, BMFace *efa)
 {
@@ -133,20 +131,18 @@ bool uvedit_face_select_test_ex(const ToolSettings *ts, BMFace *efa, const int c
   if (ts->uv_flag & UV_SYNC_SELECTION) {
     return (BM_elem_flag_test(efa, BM_ELEM_SELECT));
   }
-  else {
-    BMLoop *l;
-    MLoopUV *luv;
-    BMIter liter;
 
-    BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
-      luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
-      if (!(luv->flag & MLOOPUV_VERTSEL)) {
-        return false;
-      }
-    }
+  BMLoop *l;
+  MLoopUV *luv;
+  BMIter liter;
 
-    return true;
+  BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
+    luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+    if (!(luv->flag & MLOOPUV_VERTSEL)) {
+      return false;
+    }
   }
+  return true;
 }
 bool uvedit_face_select_test(const Scene *scene, BMFace *efa, const int cd_loop_uv_offset)
 {
@@ -163,9 +159,7 @@ bool uvedit_face_select_set(const struct Scene *scene,
   if (select) {
     return uvedit_face_select_enable(scene, em, efa, do_history, cd_loop_uv_offset);
   }
-  else {
-    return uvedit_face_select_disable(scene, em, efa, cd_loop_uv_offset);
-  }
+  return uvedit_face_select_disable(scene, em, efa, cd_loop_uv_offset);
 }
 
 bool uvedit_face_select_enable(const Scene *scene,
@@ -230,22 +224,19 @@ bool uvedit_edge_select_test_ex(const ToolSettings *ts, BMLoop *l, const int cd_
     if (ts->selectmode & SCE_SELECT_FACE) {
       return BM_elem_flag_test(l->f, BM_ELEM_SELECT);
     }
-    else if (ts->selectmode == SCE_SELECT_EDGE) {
+    if (ts->selectmode == SCE_SELECT_EDGE) {
       return BM_elem_flag_test(l->e, BM_ELEM_SELECT);
     }
-    else {
-      return BM_elem_flag_test(l->v, BM_ELEM_SELECT) &&
-             BM_elem_flag_test(l->next->v, BM_ELEM_SELECT);
-    }
+    return BM_elem_flag_test(l->v, BM_ELEM_SELECT) &&
+           BM_elem_flag_test(l->next->v, BM_ELEM_SELECT);
   }
-  else {
-    MLoopUV *luv1, *luv2;
 
-    luv1 = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
-    luv2 = BM_ELEM_CD_GET_VOID_P(l->next, cd_loop_uv_offset);
+  MLoopUV *luv1, *luv2;
 
-    return (luv1->flag & MLOOPUV_VERTSEL) && (luv2->flag & MLOOPUV_VERTSEL);
-  }
+  luv1 = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+  luv2 = BM_ELEM_CD_GET_VOID_P(l->next, cd_loop_uv_offset);
+
+  return (luv1->flag & MLOOPUV_VERTSEL) && (luv2->flag & MLOOPUV_VERTSEL);
 }
 bool uvedit_edge_select_test(const Scene *scene, BMLoop *l, const int cd_loop_uv_offset)
 {
@@ -341,14 +332,11 @@ bool uvedit_uv_select_test_ex(const ToolSettings *ts, BMLoop *l, const int cd_lo
     if (ts->selectmode & SCE_SELECT_FACE) {
       return BM_elem_flag_test_bool(l->f, BM_ELEM_SELECT);
     }
-    else {
-      return BM_elem_flag_test_bool(l->v, BM_ELEM_SELECT);
-    }
-  }
-  else {
-    MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
-    return (luv->flag & MLOOPUV_VERTSEL) != 0;
+    return BM_elem_flag_test_bool(l->v, BM_ELEM_SELECT);
   }
+
+  MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+  return (luv->flag & MLOOPUV_VERTSEL) != 0;
 }
 bool uvedit_uv_select_test(const Scene *scene, BMLoop *l, const int cd_loop_uv_offset)
 {
@@ -667,9 +655,7 @@ bool ED_uvedit_nearest_uv(
     *dist_sq = dist_best;
     return true;
   }
-  else {
-    return false;
-  }
+  return false;
 }
 
 bool ED_uvedit_nearest_uv_multi(const Scene *scene,
@@ -1011,7 +997,7 @@ static void uv_select_linked_multi(Scene *scene,
           if ((startv != iterv) && (iterv->separate)) {
             break;
           }
-          else if (!flag[iterv->poly_index]) {
+          if (!flag[iterv->poly_index]) {
             flag[iterv->poly_index] = 1;
             stack[stacksize] = iterv->poly_index;
             stacksize++;
@@ -1289,17 +1275,16 @@ bool uvedit_select_is_any_selected(Scene *scene, Object *obedit)
   if (ts->uv_flag & UV_SYNC_SELECTION) {
     return (em->bm->totvertsel || em->bm->totedgesel || em->bm->totfacesel);
   }
-  else {
-    const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
-    BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
-      if (!uvedit_face_visible_test(scene, efa)) {
-        continue;
-      }
-      BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
-        luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
-        if (luv->flag & MLOOPUV_VERTSEL) {
-          return true;
-        }
+
+  const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
+  BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
+    if (!uvedit_face_visible_test(scene, efa)) {
+      continue;
+    }
+    BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
+      luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+      if (luv->

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list