Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2020-08-07 12:23:02 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-08-07 12:23:02 +0300
commita29686eeb3af051a00fbb8a8b9be06bcd050ec8c (patch)
tree9da60e7257e3e2dafda3e9b565b77c9c6f37675b /source/blender/blenlib
parente0c51b466f3b23a1fc114690be2b008e19637ea6 (diff)
Cleanup: Blenlib, Clang-Tidy else-after-return fixes (incomplete)
This addresses warnings from Clang-Tidy's `readability-else-after-return` rule in the `source/blender/blenlib` module. Not all warnings are addressed in this commit. No functional changes.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/intern/BLI_args.c8
-rw-r--r--source/blender/blenlib/intern/BLI_ghash.c42
-rw-r--r--source/blender/blenlib/intern/BLI_kdopbvh.c90
-rw-r--r--source/blender/blenlib/intern/BLI_linklist.c2
-rw-r--r--source/blender/blenlib/intern/BLI_memiter.c16
-rw-r--r--source/blender/blenlib/intern/DLRB_tree.c8
-rw-r--r--source/blender/blenlib/intern/array_store.c26
-rw-r--r--source/blender/blenlib/intern/array_utils.c2
-rw-r--r--source/blender/blenlib/intern/bitmap_draw_2d.c28
-rw-r--r--source/blender/blenlib/intern/boxpack_2d.c8
-rw-r--r--source/blender/blenlib/intern/convexhull_2d.c17
-rw-r--r--source/blender/blenlib/intern/delaunay_2d.c48
-rw-r--r--source/blender/blenlib/intern/dot_export.cc4
-rw-r--r--source/blender/blenlib/intern/easing.c35
-rw-r--r--source/blender/blenlib/intern/edgehash.c14
-rw-r--r--source/blender/blenlib/intern/fileops.c15
-rw-r--r--source/blender/blenlib/intern/lasso_2d.c7
-rw-r--r--source/blender/blenlib/intern/listbase.c5
-rw-r--r--source/blender/blenlib/intern/math_color.c10
-rw-r--r--source/blender/blenlib/intern/math_geom.c584
-rw-r--r--source/blender/blenlib/intern/math_rotation.c30
-rw-r--r--source/blender/blenlib/intern/math_vector.c18
-rw-r--r--source/blender/blenlib/intern/path_util.c73
-rw-r--r--source/blender/blenlib/intern/polyfill_2d.c14
-rw-r--r--source/blender/blenlib/intern/polyfill_2d_beautify.c15
-rw-r--r--source/blender/blenlib/intern/quadric.c10
-rw-r--r--source/blender/blenlib/intern/rct.c194
-rw-r--r--source/blender/blenlib/intern/scanfill.c96
-rw-r--r--source/blender/blenlib/intern/scanfill_utils.c5
-rw-r--r--source/blender/blenlib/intern/smallhash.c7
-rw-r--r--source/blender/blenlib/intern/sort_utils.c42
-rw-r--r--source/blender/blenlib/intern/storage.c4
-rw-r--r--source/blender/blenlib/intern/string.c32
-rw-r--r--source/blender/blenlib/intern/string_utf8.c8
-rw-r--r--source/blender/blenlib/intern/string_utils.c2
-rw-r--r--source/blender/blenlib/intern/threads.cc4
36 files changed, 669 insertions, 854 deletions
diff --git a/source/blender/blenlib/intern/BLI_args.c b/source/blender/blenlib/intern/BLI_args.c
index 2b078b3bae5..91aabca7747 100644
--- a/source/blender/blenlib/intern/BLI_args.c
+++ b/source/blender/blenlib/intern/BLI_args.c
@@ -92,13 +92,9 @@ static bool keycmp(const void *a, const void *b)
if (ka->case_str == 1 || kb->case_str == 1) {
return (BLI_strcasecmp(ka->arg, kb->arg) != 0);
}
- else {
- return (!STREQ(ka->arg, kb->arg));
- }
- }
- else {
- return BLI_ghashutil_intcmp((const void *)ka->pass, (const void *)kb->pass);
+ return (!STREQ(ka->arg, kb->arg));
}
+ return BLI_ghashutil_intcmp((const void *)ka->pass, (const void *)kb->pass);
}
static bArgument *lookUp(struct bArgs *ba, const char *arg, int pass, int case_str)
diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c
index 09dbf18acd0..69602cd4209 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -538,10 +538,8 @@ BLI_INLINE bool ghash_insert_safe(GHash *gh,
}
return false;
}
- else {
- ghash_insert_ex(gh, key, val, bucket_index);
- return true;
- }
+ ghash_insert_ex(gh, key, val, bucket_index);
+ return true;
}
BLI_INLINE bool ghash_insert_safe_keyonly(GHash *gh,
@@ -564,10 +562,8 @@ BLI_INLINE bool ghash_insert_safe_keyonly(GHash *gh,
}
return false;
}
- else {
- ghash_insert_ex_keyonly(gh, key, bucket_index);
- return true;
- }
+ ghash_insert_ex_keyonly(gh, key, bucket_index);
+ return true;
}
/**
@@ -792,9 +788,7 @@ void *BLI_ghash_replace_key(GHash *gh, void *key)
e->e.key = key;
return key_prev;
}
- else {
- return NULL;
- }
+ return NULL;
}
/**
@@ -915,9 +909,7 @@ bool BLI_ghash_remove(GHash *gh,
BLI_mempool_free(gh->entrypool, e);
return true;
}
- else {
- return false;
- }
+ return false;
}
/* same as above but return the value,
@@ -940,9 +932,7 @@ void *BLI_ghash_popkey(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp)
BLI_mempool_free(gh->entrypool, e);
return val;
}
- else {
- return NULL;
- }
+ return NULL;
}
/**
@@ -975,10 +965,9 @@ bool BLI_ghash_pop(GHash *gh, GHashIterState *state, void **r_key, void **r_val)
BLI_mempool_free(gh->entrypool, e);
return true;
}
- else {
- *r_key = *r_val = NULL;
- return false;
- }
+
+ *r_key = *r_val = NULL;
+ return false;
}
/**
@@ -1246,10 +1235,9 @@ bool BLI_gset_pop(GSet *gs, GSetIterState *state, void **r_key)
BLI_mempool_free(((GHash *)gs)->entrypool, e);
return true;
}
- else {
- *r_key = NULL;
- return false;
- }
+
+ *r_key = NULL;
+ return false;
}
void BLI_gset_clear_ex(GSet *gs, GSetKeyFreeFP keyfreefp, const uint nentries_reserve)
@@ -1309,9 +1297,7 @@ void *BLI_gset_pop_key(GSet *gs, const void *key)
BLI_mempool_free(((GHash *)gs)->entrypool, e);
return key_ret;
}
- else {
- return NULL;
- }
+ return NULL;
}
/** \} */
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c
index a3f93ccc753..f63a523ca60 100644
--- a/source/blender/blenlib/intern/BLI_kdopbvh.c
+++ b/source/blender/blenlib/intern/BLI_kdopbvh.c
@@ -284,28 +284,19 @@ static BVHNode *bvh_medianof3(BVHNode **a, int lo, int mid, int hi, int axis)
if ((a[hi])->bv[axis] < (a[mid])->bv[axis]) {
return a[mid];
}
- else {
- if ((a[hi])->bv[axis] < (a[lo])->bv[axis]) {
- return a[hi];
- }
- else {
- return a[lo];
- }
+ if ((a[hi])->bv[axis] < (a[lo])->bv[axis]) {
+ return a[hi];
}
+ return a[lo];
}
- else {
- if ((a[hi])->bv[axis] < (a[mid])->bv[axis]) {
- if ((a[hi])->bv[axis] < (a[lo])->bv[axis]) {
- return a[lo];
- }
- else {
- return a[hi];
- }
- }
- else {
- return a[mid];
+
+ if ((a[hi])->bv[axis] < (a[mid])->bv[axis]) {
+ if ((a[hi])->bv[axis] < (a[lo])->bv[axis]) {
+ return a[lo];
}
+ return a[hi];
}
+ return a[mid];
}
/**
@@ -422,18 +413,12 @@ static char get_largest_axis(const float *bv)
if (middle_point[0] > middle_point[2]) {
return 1; /* max x axis */
}
- else {
- return 5; /* max z axis */
- }
+ return 5; /* max z axis */
}
- else {
- if (middle_point[1] > middle_point[2]) {
- return 3; /* max y axis */
- }
- else {
- return 5; /* max z axis */
- }
+ if (middle_point[1] > middle_point[2]) {
+ return 3; /* max y axis */
}
+ return 5; /* max z axis */
}
/**
@@ -619,13 +604,11 @@ static int implicit_leafs_index(const BVHBuildHelper *data, const int depth, con
if (min_leaf_index <= data->remain_leafs) {
return min_leaf_index;
}
- else if (data->leafs_per_child[depth]) {
+ if (data->leafs_per_child[depth]) {
return data->totleafs -
(data->branches_on_level[depth - 1] - child_index) * data->leafs_per_child[depth];
}
- else {
- return data->remain_leafs;
- }
+ return data->remain_leafs;
}
/**
@@ -1668,10 +1651,8 @@ static bool dfs_find_duplicate_fast_dfs(BVHNearestData *data, BVHNode *node)
data->callback(data->userdata, node->index, data->co, &data->nearest);
return (data->nearest.dist_sq < dist_sq);
}
- else {
- data->nearest.index = node->index;
- return true;
- }
+ data->nearest.index = node->index;
+ return true;
}
}
else {
@@ -1805,9 +1786,7 @@ static float fast_ray_nearest_hit(const BVHRayCastData *data, const BVHNode *nod
(t1x > data->hit.dist || t1y > data->hit.dist || t1z > data->hit.dist)) {
return FLT_MAX;
}
- else {
- return max_fff(t1x, t1y, t1z);
- }
+ return max_fff(t1x, t1y, t1z);
}
static void dfs_raycast(BVHRayCastData *data, BVHNode *node)
@@ -2354,26 +2333,25 @@ static bool bvhtree_walk_dfs_recursive(BVHTree_WalkData *walk_data, const BVHNod
return walk_data->walk_leaf_cb(
(const BVHTreeAxisRange *)node->bv, node->index, walk_data->userdata);
}
- else {
- /* First pick the closest node to recurse into */
- if (walk_data->walk_order_cb(
- (const BVHTreeAxisRange *)node->bv, node->main_axis, walk_data->userdata)) {
- for (int i = 0; i != node->totnode; i++) {
- if (walk_data->walk_parent_cb((const BVHTreeAxisRange *)node->children[i]->bv,
- walk_data->userdata)) {
- if (!bvhtree_walk_dfs_recursive(walk_data, node->children[i])) {
- return false;
- }
+
+ /* First pick the closest node to recurse into */
+ if (walk_data->walk_order_cb(
+ (const BVHTreeAxisRange *)node->bv, node->main_axis, walk_data->userdata)) {
+ for (int i = 0; i != node->totnode; i++) {
+ if (walk_data->walk_parent_cb((const BVHTreeAxisRange *)node->children[i]->bv,
+ walk_data->userdata)) {
+ if (!bvhtree_walk_dfs_recursive(walk_data, node->children[i])) {
+ return false;
}
}
}
- else {
- for (int i = node->totnode - 1; i >= 0; i--) {
- if (walk_data->walk_parent_cb((const BVHTreeAxisRange *)node->children[i]->bv,
- walk_data->userdata)) {
- if (!bvhtree_walk_dfs_recursive(walk_data, node->children[i])) {
- return false;
- }
+ }
+ else {
+ for (int i = node->totnode - 1; i >= 0; i--) {
+ if (walk_data->walk_parent_cb((const BVHTreeAxisRange *)node->children[i]->bv,
+ walk_data->userdata)) {
+ if (!bvhtree_walk_dfs_recursive(walk_data, node->children[i])) {
+ return false;
}
}
}
diff --git a/source/blender/blenlib/intern/BLI_linklist.c b/source/blender/blenlib/intern/BLI_linklist.c
index dc5d20ece99..4cac526088b 100644
--- a/source/blender/blenlib/intern/BLI_linklist.c
+++ b/source/blender/blenlib/intern/BLI_linklist.c
@@ -147,7 +147,7 @@ void BLI_linklist_move_item(LinkNode **listp, int curr_index, int new_index)
lnk_pdst = lnk;
break;
}
- else if (i == curr_index - 1) {
+ if (i == curr_index - 1) {
lnk_psrc = lnk;
}
}
diff --git a/source/blender/blenlib/intern/BLI_memiter.c b/source/blender/blenlib/intern/BLI_memiter.c
index 1b9509e36d8..428dd1e2ad8 100644
--- a/source/blender/blenlib/intern/BLI_memiter.c
+++ b/source/blender/blenlib/intern/BLI_memiter.c
@@ -269,9 +269,7 @@ void *BLI_memiter_elem_first(BLI_memiter *mi)
BLI_memiter_elem *elem = (BLI_memiter_elem *)chunk->data;
return elem->data;
}
- else {
- return NULL;
- }
+ return NULL;
}
void *BLI_memiter_elem_first_size(BLI_memiter *mi, uint *r_size)
@@ -282,9 +280,7 @@ void *BLI_memiter_elem_first_size(BLI_memiter *mi, uint *r_size)
*r_size = (uint)elem->size;
return elem->data;
}
- else {
- return NULL;
- }
+ return NULL;
}
/** \} */
@@ -334,9 +330,7 @@ void *BLI_memiter_iter_step_size(BLI_memiter_handle *iter, uint *r_size)
iter->elem = (BLI_memiter_elem *)&data[data_offset_from_size(size)];
return (void *)data;
}
- else {
- return NULL;
- }
+ return NULL;
}
void *BLI_memiter_iter_step(BLI_memiter_handle *iter)
@@ -352,9 +346,7 @@ void *BLI_memiter_iter_step(BLI_memiter_handle *iter)
iter->elem = (BLI_memiter_elem *)&data[data_offset_from_size(size)];
return (void *)data;
}
- else {
- return NULL;
- }
+ return NULL;
}
/** \} */
diff --git a/source/blender/blenlib/intern/DLRB_tree.c b/source/blender/blenlib/intern/DLRB_tree.c
index 6810601d527..b0c3379ac97 100644
--- a/source/blender/blenlib/intern/DLRB_tree.c
+++ b/source/blender/blenlib/intern/DLRB_tree.c
@@ -299,9 +299,7 @@ static DLRBT_Node *get_grandparent(DLRBT_Node *node)
if (node && node->parent) {
return node->parent->parent;
}
- else {
- return NULL;
- }
+ return NULL;
}
/* get the sibling node (e.g. if node is left child of parent, return right child of parent) */
@@ -311,9 +309,7 @@ static DLRBT_Node *get_sibling(DLRBT_Node *node)
if (node == node->parent->left) {
return node->parent->right;
}
- else {
- return node->parent->left;
- }
+ return node->parent->left;
}
/* sibling not found */
diff --git a/source/blender/blenlib/intern/array_store.c b/source/blender/blenlib/intern/array_store.c
index 85fbe7ece0f..387f9837159 100644
--- a/source/blender/blenlib/intern/array_store.c
+++ b/source/blender/blenlib/intern/array_store.c
@@ -355,9 +355,7 @@ static bool bchunk_data_compare(const BChunk *chunk,
if (offset + (size_t)chunk->data_len <= data_base_len) {
return (memcmp(&data_base[offset], chunk->data, chunk->data_len) == 0);
}
- else {
- return false;
- }
+ return false;
}
/** \} */
@@ -893,20 +891,18 @@ static hash_key key_from_chunk_ref(const BArrayInfo *info,
# endif
return key;
}
- else {
- /* corner case - we're too small, calculate the key each time. */
+ /* corner case - we're too small, calculate the key each time. */
- hash_array_from_cref(info, cref, info->accum_read_ahead_bytes, hash_store);
- hash_accum_single(hash_store, hash_store_len, info->accum_steps);
- hash_key key = hash_store[0];
+ hash_array_from_cref(info, cref, info->accum_read_ahead_bytes, hash_store);
+ hash_accum_single(hash_store, hash_store_len, info->accum_steps);
+ hash_key key = hash_store[0];
# ifdef USE_HASH_TABLE_KEY_CACHE
- if (UNLIKELY(key == HASH_TABLE_KEY_UNSET)) {
- key = HASH_TABLE_KEY_FALLBACK;
- }
-# endif
- return key;
+ if (UNLIKELY(key == HASH_TABLE_KEY_UNSET)) {
+ key = HASH_TABLE_KEY_FALLBACK;
}
+# endif
+ return key;
}
static const BChunkRef *table_lookup(const BArrayInfo *info,
@@ -1083,9 +1079,7 @@ static BChunkList *bchunk_list_from_data_merge(const BArrayInfo *info,
if (cref == cref_match_first) {
break;
}
- else {
- cref = cref->next;
- }
+ cref = cref->next;
}
/* happens when bytes are removed from the end of the array */
if (chunk_size_step == data_len_original) {
diff --git a/source/blender/blenlib/intern/array_utils.c b/source/blender/blenlib/intern/array_utils.c
index 5dec10a5756..e9ef5e2a927 100644
--- a/source/blender/blenlib/intern/array_utils.c
+++ b/source/blender/blenlib/intern/array_utils.c
@@ -208,7 +208,7 @@ bool _bli_array_iter_span(const void *arr,
if (arr_len == 0) {
return false;
}
- else if (use_wrap && (span_step[0] != arr_len) && (span_step[0] > span_step[1])) {
+ if (use_wrap && (span_step[0] != arr_len) && (span_step[0] > span_step[1])) {
return false;
}
diff --git a/source/blender/blenlib/intern/bitmap_draw_2d.c b/source/blender/blenlib/intern/bitmap_draw_2d.c
index 17debb38326..33250105c79 100644
--- a/source/blender/blenlib/intern/bitmap_draw_2d.c
+++ b/source/blender/blenlib/intern/bitmap_draw_2d.c
@@ -316,27 +316,25 @@ static int draw_poly_v2i_n__span_y_sort(const void *a_p, const void *b_p, void *
if (co_a[1] < co_b[1]) {
return -1;
}
- else if (co_a[1] > co_b[1]) {
+ if (co_a[1] > co_b[1]) {
return 1;
}
- else if (co_a[0] < co_b[0]) {
+ if (co_a[0] < co_b[0]) {
return -1;
}
- else if (co_a[0] > co_b[0]) {
+ if (co_a[0] > co_b[0]) {
return 1;
}
- else {
- /* co_a & co_b are identical, use the line closest to the x-min */
- const int *co = co_a;
- co_a = verts[a[1]];
- co_b = verts[b[1]];
- int ord = (((co_b[0] - co[0]) * (co_a[1] - co[1])) - ((co_a[0] - co[0]) * (co_b[1] - co[1])));
- if (ord > 0) {
- return -1;
- }
- if (ord < 0) {
- return 1;
- }
+ /* co_a & co_b are identical, use the line closest to the x-min */
+ const int *co = co_a;
+ co_a = verts[a[1]];
+ co_b = verts[b[1]];
+ int ord = (((co_b[0] - co[0]) * (co_a[1] - co[1])) - ((co_a[0] - co[0]) * (co_b[1] - co[1])));
+ if (ord > 0) {
+ return -1;
+ }
+ if (ord < 0) {
+ return 1;
}
return 0;
}
diff --git a/source/blender/blenlib/intern/boxpack_2d.c b/source/blender/blenlib/intern/boxpack_2d.c
index 83866f766df..5bcb0c0322a 100644
--- a/source/blender/blenlib/intern/boxpack_2d.c
+++ b/source/blender/blenlib/intern/boxpack_2d.c
@@ -216,7 +216,7 @@ static int box_areasort(const void *p1, const void *p2)
if (a1 < a2) {
return 1;
}
- else if (a1 > a2) {
+ if (a1 > a2) {
return -1;
}
return 0;
@@ -246,10 +246,10 @@ static int vertex_sort(const void *p1, const void *p2, void *vs_ctx_p)
if (UNLIKELY(v1->free == 0 && v2->free == 0)) {
return 0;
}
- else if (UNLIKELY(v1->free == 0)) {
+ if (UNLIKELY(v1->free == 0)) {
return 1;
}
- else if (UNLIKELY(v2->free == 0)) {
+ if (UNLIKELY(v2->free == 0)) {
return -1;
}
#endif
@@ -266,7 +266,7 @@ static int vertex_sort(const void *p1, const void *p2, void *vs_ctx_p)
if (a1 > a2) {
return 1;
}
- else if (a1 < a2) {
+ if (a1 < a2) {
return -1;
}
return 0;
diff --git a/source/blender/blenlib/intern/convexhull_2d.c b/source/blender/blenlib/intern/convexhull_2d.c
index b37dc73db29..6e4a8623077 100644
--- a/source/blender/blenlib/intern/convexhull_2d.c
+++ b/source/blender/blenlib/intern/convexhull_2d.c
@@ -115,9 +115,7 @@ int BLI_convexhull_2d_sorted(const float (*points)[2], const int n, int r_points
if (is_left(points[r_points[top - 1]], points[r_points[top]], points[i]) > 0.0f) {
break; /* points[i] is a new hull vertex */
}
- else {
- top--; /* pop top point off stack */
- }
+ top--; /* pop top point off stack */
}
r_points[++top] = i; /* push points[i] onto stack */
@@ -141,9 +139,7 @@ int BLI_convexhull_2d_sorted(const float (*points)[2], const int n, int r_points
if (is_left(points[r_points[top - 1]], points[r_points[top]], points[i]) > 0.0f) {
break; /* points[i] is a new hull vertex */
}
- else {
- top--; /* pop top point off stack */
- }
+ top--; /* pop top point off stack */
}
if (points[i][0] == points[r_points[0]][0] && points[i][1] == points[r_points[0]][1]) {
@@ -172,20 +168,17 @@ static int pointref_cmp_yx(const void *a_, const void *b_)
if (a->pt[1] > b->pt[1]) {
return 1;
}
- else if (a->pt[1] < b->pt[1]) {
+ if (a->pt[1] < b->pt[1]) {
return -1;
}
if (a->pt[0] > b->pt[0]) {
return 1;
}
- else if (a->pt[0] < b->pt[0]) {
+ if (a->pt[0] < b->pt[0]) {
return -1;
}
-
- else {
- return 0;
- }
+ return 0;
}
/**
diff --git a/source/blender/blenlib/intern/delaunay_2d.c b/source/blender/blenlib/intern/delaunay_2d.c
index 5f663dcb2e1..7199e461c6c 100644
--- a/source/blender/blenlib/intern/delaunay_2d.c
+++ b/source/blender/blenlib/intern/delaunay_2d.c
@@ -600,19 +600,19 @@ static int site_lexicographic_cmp(const void *a, const void *b)
if (co1[0] < co2[0]) {
return -1;
}
- else if (co1[0] > co2[0]) {
+ if (co1[0] > co2[0]) {
return 1;
}
- else if (co1[1] < co2[1]) {
+ if (co1[1] < co2[1]) {
return -1;
}
- else if (co1[1] > co2[1]) {
+ if (co1[1] > co2[1]) {
return 1;
}
- else if (s1->orig_index < s2->orig_index) {
+ if (s1->orig_index < s2->orig_index) {
return -1;
}
- else if (s1->orig_index > s2->orig_index) {
+ if (s1->orig_index > s2->orig_index) {
return 1;
}
return 0;
@@ -974,7 +974,7 @@ static void initial_triangulation(CDT_state *cdt)
if (jco[0] > xend) {
break; /* No more j's to process. */
}
- else if (jco[1] > yend) {
+ if (jco[1] > yend) {
/* Get past any string of v's with the same x and too-big y. */
xcur = jco[0];
while (++j < n) {
@@ -1414,7 +1414,7 @@ static bool get_next_crossing_from_vert(CDT_state *cdt,
ok = true;
break;
}
- else if (t->face != cdt->outer_face) {
+ if (t->face != cdt->outer_face) {
orient2 = orient2d(vcur->co, vb->co, v2->co);
#ifdef DEBUG_CDT
if (dbg_level > 1) {
@@ -1683,14 +1683,12 @@ static void add_edge_constraint(
(cd_prev->lambda != 0.0 && cd_prev->in->vert != v && cd_prev->in->next->vert != v)) {
break;
}
- else {
- cd_prev->lambda = -1.0; /* Mark cd_prev as 'deleted'. */
+ cd_prev->lambda = -1.0; /* Mark cd_prev as 'deleted'. */
#ifdef DEBUG_CDT
- if (dbg_level > 0) {
- fprintf(stderr, "deleted crossing %d\n", j);
- }
-#endif
+ if (dbg_level > 0) {
+ fprintf(stderr, "deleted crossing %d\n", j);
}
+#endif
}
if (j < i - 1) {
/* Some crossings were deleted. Fix the in and out edges across gap. */
@@ -2002,19 +2000,19 @@ static int evl_cmp(const void *a, const void *b)
if (area->e_id < sb->e_id) {
return -1;
}
- else if (area->e_id > sb->e_id) {
+ if (area->e_id > sb->e_id) {
return 1;
}
- else if (area->lambda < sb->lambda) {
+ if (area->lambda < sb->lambda) {
return -1;
}
- else if (area->lambda > sb->lambda) {
+ if (area->lambda > sb->lambda) {
return 1;
}
- else if (area->v_id < sb->v_id) {
+ if (area->v_id < sb->v_id) {
return -1;
}
- else if (area->v_id > sb->v_id) {
+ if (area->v_id > sb->v_id) {
return 1;
}
return 0;
@@ -2386,9 +2384,7 @@ static const CDT_input *modify_input_for_near_edge_ends(const CDT_input *input,
if (new_input != NULL) {
return (const CDT_input *)new_input;
}
- else {
- return input;
- }
+ return input;
}
static void free_modified_input(CDT_input *input)
@@ -2745,7 +2741,7 @@ static int edge_to_sort_cmp(const void *a, const void *b)
if (e1->len_squared > e2->len_squared) {
return -1;
}
- else if (e1->len_squared < e2->len_squared) {
+ if (e1->len_squared < e2->len_squared) {
return 1;
}
return 0;
@@ -4570,17 +4566,13 @@ static double orient2d(const double *pa, const double *pb, const double *pc)
if (detright <= 0.0) {
return det;
}
- else {
- detsum = detleft + detright;
- }
+ detsum = detleft + detright;
}
else if (detleft < 0.0) {
if (detright >= 0.0) {
return det;
}
- else {
- detsum = -detleft - detright;
- }
+ detsum = -detleft - detright;
}
else {
return det;
diff --git a/source/blender/blenlib/intern/dot_export.cc b/source/blender/blenlib/intern/dot_export.cc
index 8e4aafa4bb8..9ffb1895d04 100644
--- a/source/blender/blenlib/intern/dot_export.cc
+++ b/source/blender/blenlib/intern/dot_export.cc
@@ -60,7 +60,7 @@ void Cluster::set_parent_cluster(Cluster *new_parent)
if (parent_ == new_parent) {
return;
}
- else if (parent_ == nullptr) {
+ if (parent_ == nullptr) {
graph_.top_level_clusters_.remove(this);
new_parent->children_.add_new(this);
}
@@ -80,7 +80,7 @@ void Node::set_parent_cluster(Cluster *cluster)
if (cluster_ == cluster) {
return;
}
- else if (cluster_ == nullptr) {
+ if (cluster_ == nullptr) {
graph_.top_level_nodes_.remove(this);
cluster->nodes_.add_new(this);
}
diff --git a/source/blender/blenlib/intern/easing.c b/source/blender/blenlib/intern/easing.c
index 9532f78bd44..07aafc1b57b 100644
--- a/source/blender/blenlib/intern/easing.c
+++ b/source/blender/blenlib/intern/easing.c
@@ -72,18 +72,16 @@ float BLI_easing_bounce_ease_out(float time, float begin, float change, float du
if (time < (1 / 2.75f)) {
return change * (7.5625f * time * time) + begin;
}
- else if (time < (2 / 2.75f)) {
+ if (time < (2 / 2.75f)) {
time -= (1.5f / 2.75f);
return change * ((7.5625f * time) * time + 0.75f) + begin;
}
- else if (time < (2.5f / 2.75f)) {
+ if (time < (2.5f / 2.75f)) {
time -= (2.25f / 2.75f);
return change * ((7.5625f * time) * time + 0.9375f) + begin;
}
- else {
- time -= (2.625f / 2.75f);
- return change * ((7.5625f * time) * time + 0.984375f) + begin;
- }
+ time -= (2.625f / 2.75f);
+ return change * ((7.5625f * time) * time + 0.984375f) + begin;
}
float BLI_easing_bounce_ease_in(float time, float begin, float change, float duration)
@@ -96,10 +94,8 @@ float BLI_easing_bounce_ease_in_out(float time, float begin, float change, float
if (time < duration / 2) {
return BLI_easing_bounce_ease_in(time * 2, 0, change, duration) * 0.5f + begin;
}
- else {
- return BLI_easing_bounce_ease_out(time * 2 - duration, 0, change, duration) * 0.5f +
- change * 0.5f + begin;
- }
+ return BLI_easing_bounce_ease_out(time * 2 - duration, 0, change, duration) * 0.5f +
+ change * 0.5f + begin;
}
float BLI_easing_circ_ease_in(float time, float begin, float change, float duration)
@@ -271,13 +267,12 @@ float BLI_easing_elastic_ease_in_out(
sinf((time * duration - s) * (2 * (float)M_PI) / period))) +
begin;
}
- else {
- time = -time;
- f *= 0.5f;
- return (f * (amplitude * powf(2, 10 * time) *
- sinf((time * duration - s) * (2 * (float)M_PI) / period))) +
- change + begin;
- }
+
+ time = -time;
+ f *= 0.5f;
+ return (f * (amplitude * powf(2, 10 * time) *
+ sinf((time * duration - s) * (2 * (float)M_PI) / period))) +
+ change + begin;
}
static const float pow_min = 0.0009765625f; /* = 2^(-10) */
@@ -306,10 +301,8 @@ float BLI_easing_expo_ease_in_out(float time, float begin, float change, float d
if (time <= duration_half) {
return BLI_easing_expo_ease_in(time, begin, change_half, duration_half);
}
- else {
- return BLI_easing_expo_ease_out(
- time - duration_half, begin + change_half, change_half, duration_half);
- }
+ return BLI_easing_expo_ease_out(
+ time - duration_half, begin + change_half, change_half, duration_half);
}
float BLI_easing_linear_ease(float time, float begin, float change, float duration)
diff --git a/source/blender/blenlib/intern/edgehash.c b/source/blender/blenlib/intern/edgehash.c
index 56529581dd3..05ee02ad869 100644
--- a/source/blender/blenlib/intern/edgehash.c
+++ b/source/blender/blenlib/intern/edgehash.c
@@ -185,7 +185,7 @@ BLI_INLINE EdgeHashEntry *edgehash_insert(EdgeHash *eh, Edge edge, void *value)
if (index == SLOT_EMPTY) {
return edgehash_insert_at_slot(eh, slot, edge, value);
}
- else if (index == SLOT_DUMMY) {
+ if (index == SLOT_DUMMY) {
eh->dummy_count--;
return edgehash_insert_at_slot(eh, slot, edge, value);
}
@@ -200,7 +200,7 @@ BLI_INLINE EdgeHashEntry *edgehash_lookup_entry(EdgeHash *eh, uint v0, uint v1)
if (EH_INDEX_HAS_EDGE(eh, index, edge)) {
return &eh->entries[index];
}
- else if (index == SLOT_EMPTY) {
+ if (index == SLOT_EMPTY) {
return NULL;
}
}
@@ -294,7 +294,7 @@ bool BLI_edgehash_reinsert(EdgeHash *eh, uint v0, uint v1, void *value)
eh->entries[index].value = value;
return false;
}
- else if (index == SLOT_EMPTY) {
+ if (index == SLOT_EMPTY) {
if (edgehash_ensure_can_insert(eh)) {
edgehash_insert(eh, edge, value);
}
@@ -360,7 +360,7 @@ bool BLI_edgehash_ensure_p(EdgeHash *eh, uint v0, uint v1, void ***r_value)
*r_value = &eh->entries[index].value;
return true;
}
- else if (index == SLOT_EMPTY) {
+ if (index == SLOT_EMPTY) {
if (edgehash_ensure_can_insert(eh)) {
*r_value = &edgehash_insert(eh, edge, NULL)->value;
}
@@ -413,7 +413,7 @@ void *BLI_edgehash_popkey(EdgeHash *eh, uint v0, uint v1)
}
return value;
}
- else if (index == SLOT_EMPTY) {
+ if (index == SLOT_EMPTY) {
return NULL;
}
}
@@ -583,7 +583,7 @@ bool BLI_edgeset_add(EdgeSet *es, uint v0, uint v1)
if (ES_INDEX_HAS_EDGE(es, index, edge)) {
return false;
}
- else if (index == SLOT_EMPTY) {
+ if (index == SLOT_EMPTY) {
edgeset_insert_at_slot(es, slot, edge);
return true;
}
@@ -615,7 +615,7 @@ bool BLI_edgeset_haskey(EdgeSet *es, uint v0, uint v1)
if (ES_INDEX_HAS_EDGE(es, index, edge)) {
return true;
}
- else if (index == SLOT_EMPTY) {
+ if (index == SLOT_EMPTY) {
return false;
}
}
diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c
index e61cbd318fc..6c7383bc297 100644
--- a/source/blender/blenlib/intern/fileops.c
+++ b/source/blender/blenlib/intern/fileops.c
@@ -980,7 +980,7 @@ static int delete_soft(const char *file, const char **error_message)
"Blender may not support moving files or directories to trash on your system.";
return -1;
}
- else if (WIFEXITED(wstatus) && WEXITSTATUS(wstatus)) {
+ if (WIFEXITED(wstatus) && WEXITSTATUS(wstatus)) {
*error_message = process_failed;
return -1;
}
@@ -1036,12 +1036,10 @@ int BLI_delete(const char *file, bool dir, bool recursive)
if (recursive) {
return recursive_operation(file, NULL, NULL, delete_single_file, delete_callback_post);
}
- else if (dir) {
+ if (dir) {
return rmdir(file);
}
- else {
- return remove(file);
- }
+ return remove(file);
}
/**
@@ -1184,8 +1182,7 @@ static int copy_single_file(const char *from, const char *to)
return RecursiveOp_Callback_OK;
}
- else if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode) || S_ISFIFO(st.st_mode) ||
- S_ISSOCK(st.st_mode)) {
+ if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode) || S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) {
/* copy special type of file */
if (mknod(to, st.st_mode, st.st_rdev)) {
perror("mknod");
@@ -1198,7 +1195,7 @@ static int copy_single_file(const char *from, const char *to)
return RecursiveOp_Callback_OK;
}
- else if (!S_ISREG(st.st_mode)) {
+ if (!S_ISREG(st.st_mode)) {
fprintf(stderr, "Copying of this kind of files isn't supported yet\n");
return RecursiveOp_Callback_Error;
}
@@ -1337,7 +1334,7 @@ bool BLI_dir_create_recursive(const char *dirname)
if (BLI_is_dir(dirname)) {
return true;
}
- else if (BLI_exists(dirname)) {
+ if (BLI_exists(dirname)) {
return false;
}
diff --git a/source/blender/blenlib/intern/lasso_2d.c b/source/blender/blenlib/intern/lasso_2d.c
index a01adf4fa6a..f2cc8d42de7 100644
--- a/source/blender/blenlib/intern/lasso_2d.c
+++ b/source/blender/blenlib/intern/lasso_2d.c
@@ -60,10 +60,9 @@ bool BLI_lasso_is_point_inside(const int mcoords[][2],
if (sx == error_value || mcoords_len == 0) {
return false;
}
- else {
- int pt[2] = {sx, sy};
- return isect_point_poly_v2_int(pt, mcoords, mcoords_len, true);
- }
+
+ int pt[2] = {sx, sy};
+ return isect_point_poly_v2_int(pt, mcoords, mcoords_len, true);
}
/* edge version for lasso select. we assume boundbox check was done */
diff --git a/source/blender/blenlib/intern/listbase.c b/source/blender/blenlib/intern/listbase.c
index 892eca768b3..5e88f8f3e44 100644
--- a/source/blender/blenlib/intern/listbase.c
+++ b/source/blender/blenlib/intern/listbase.c
@@ -162,9 +162,8 @@ bool BLI_remlink_safe(ListBase *listbase, void *vlink)
BLI_remlink(listbase, vlink);
return true;
}
- else {
- return false;
- }
+
+ return false;
}
/**
diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c
index 651a062e3d5..09bb7ea5711 100644
--- a/source/blender/blenlib/intern/math_color.c
+++ b/source/blender/blenlib/intern/math_color.c
@@ -439,9 +439,8 @@ float srgb_to_linearrgb(float c)
if (c < 0.04045f) {
return (c < 0.0f) ? 0.0f : c * (1.0f / 12.92f);
}
- else {
- return powf((c + 0.055f) * (1.0f / 1.055f), 2.4f);
- }
+
+ return powf((c + 0.055f) * (1.0f / 1.055f), 2.4f);
}
float linearrgb_to_srgb(float c)
@@ -449,9 +448,8 @@ float linearrgb_to_srgb(float c)
if (c < 0.0031308f) {
return (c < 0.0f) ? 0.0f : c * 12.92f;
}
- else {
- return 1.055f * powf(c, 1.0f / 2.4f) - 0.055f;
- }
+
+ return 1.055f * powf(c, 1.0f / 2.4f) - 0.055f;
}
void minmax_rgb(short c[3])
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 7c187679ad1..ce83b522178 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -231,9 +231,8 @@ float cotangent_tri_weight_v3(const float v1[3], const float v2[3], const float
if (c_len > FLT_EPSILON) {
return dot_v3v3(a, b) / c_len;
}
- else {
- return 0.0f;
- }
+
+ return 0.0f;
}
/********************************* Planes **********************************/
@@ -589,9 +588,8 @@ float dist_signed_squared_to_corner_v3v3v3(const float p[3],
if (flip) {
return min_ff(dist_a, dist_b);
}
- else {
- return max_ff(dist_a, dist_b);
- }
+
+ return max_ff(dist_a, dist_b);
}
/**
@@ -1146,9 +1144,8 @@ int isect_line_line_v2_point(
return ISECT_LINE_LINE_CROSS;
}
- else {
- return ISECT_LINE_LINE_COLINEAR;
- }
+
+ return ISECT_LINE_LINE_COLINEAR;
}
/* intersect Line-Line, floats */
@@ -1304,55 +1301,54 @@ int isect_seg_seg_v2_point_ex(const float v0[2],
/* out of segment intersection */
return -1;
}
- else {
- if ((cross_v2v2(s10, s30) == 0.0f) && (cross_v2v2(s32, s30) == 0.0f)) {
- /* equal lines */
- float s20[2];
- float u_a, u_b;
-
- if (equals_v2v2(v0, v1)) {
- if (len_squared_v2v2(v2, v3) > square_f(eps)) {
- /* use non-point segment as basis */
- SWAP(const float *, v0, v2);
- SWAP(const float *, v1, v3);
-
- sub_v2_v2v2(s10, v1, v0);
- sub_v2_v2v2(s30, v3, v0);
- }
- else { /* both of segments are points */
- if (equals_v2v2(v0, v2)) { /* points are equal */
- copy_v2_v2(r_vi, v0);
- return 1;
- }
- /* two different points */
- return -1;
- }
- }
+ if ((cross_v2v2(s10, s30) == 0.0f) && (cross_v2v2(s32, s30) == 0.0f)) {
+ /* equal lines */
+ float s20[2];
+ float u_a, u_b;
- sub_v2_v2v2(s20, v2, v0);
+ if (equals_v2v2(v0, v1)) {
+ if (len_squared_v2v2(v2, v3) > square_f(eps)) {
+ /* use non-point segment as basis */
+ SWAP(const float *, v0, v2);
+ SWAP(const float *, v1, v3);
- u_a = dot_v2v2(s20, s10) / dot_v2v2(s10, s10);
- u_b = dot_v2v2(s30, s10) / dot_v2v2(s10, s10);
-
- if (u_a > u_b) {
- SWAP(float, u_a, u_b);
+ sub_v2_v2v2(s10, v1, v0);
+ sub_v2_v2v2(s30, v3, v0);
}
+ else { /* both of segments are points */
+ if (equals_v2v2(v0, v2)) { /* points are equal */
+ copy_v2_v2(r_vi, v0);
+ return 1;
+ }
- if (u_a > endpoint_max || u_b < endpoint_min) {
- /* non-overlapping segments */
+ /* two different points */
return -1;
}
- else if (max_ff(0.0f, u_a) == min_ff(1.0f, u_b)) {
- /* one common point: can return result */
- madd_v2_v2v2fl(r_vi, v0, s10, max_ff(0, u_a));
- return 1;
- }
}
- /* lines are collinear */
- return -1;
+ sub_v2_v2v2(s20, v2, v0);
+
+ u_a = dot_v2v2(s20, s10) / dot_v2v2(s10, s10);
+ u_b = dot_v2v2(s30, s10) / dot_v2v2(s10, s10);
+
+ if (u_a > u_b) {
+ SWAP(float, u_a, u_b);
+ }
+
+ if (u_a > endpoint_max || u_b < endpoint_min) {
+ /* non-overlapping segments */
+ return -1;
+ }
+ if (max_ff(0.0f, u_a) == min_ff(1.0f, u_b)) {
+ /* one common point: can return result */
+ madd_v2_v2v2fl(r_vi, v0, s10, max_ff(0, u_a));
+ return 1;
+ }
}
+
+ /* lines are collinear */
+ return -1;
}
int isect_seg_seg_v2_point(
@@ -1472,13 +1468,13 @@ int isect_line_sphere_v3(const float l1[3],
/* no intersections */
return 0;
}
- else if (i == 0.0f) {
+ if (i == 0.0f) {
/* one intersection */
mu = -b / (2.0f * a);
madd_v3_v3v3fl(r_p1, l1, ldir, mu);
return 1;
}
- else if (i > 0.0f) {
+ if (i > 0.0f) {
const float i_sqrt = sqrtf(i); /* avoid calc twice */
/* first intersection */
@@ -1490,10 +1486,9 @@ int isect_line_sphere_v3(const float l1[3],
madd_v3_v3v3fl(r_p2, l1, ldir, mu);
return 2;
}
- else {
- /* math domain error - nan */
- return -1;
- }
+
+ /* math domain error - nan */
+ return -1;
}
/* keep in sync with isect_line_sphere_v3 */
@@ -1520,13 +1515,13 @@ int isect_line_sphere_v2(const float l1[2],
/* no intersections */
return 0;
}
- else if (i == 0.0f) {
+ if (i == 0.0f) {
/* one intersection */
mu = -b / (2.0f * a);
madd_v2_v2v2fl(r_p1, l1, ldir, mu);
return 1;
}
- else if (i > 0.0f) {
+ if (i > 0.0f) {
const float i_sqrt = sqrtf(i); /* avoid calc twice */
/* first intersection */
@@ -1538,10 +1533,9 @@ int isect_line_sphere_v2(const float l1[2],
madd_v2_v2v2fl(r_p2, l1, ldir, mu);
return 2;
}
- else {
- /* math domain error - nan */
- return -1;
- }
+
+ /* math domain error - nan */
+ return -1;
}
/* point in polygon (keep float and int versions in sync) */
@@ -1957,34 +1951,32 @@ bool isect_ray_tri_watertight_v3(const float ray_origin[3],
if (UNLIKELY(det == 0.0f || !isfinite(det))) {
return false;
}
- else {
- /* Calculate scaled z-coordinates of vertices and use them to calculate
- * the hit distance.
- */
- const int sign_det = (float_as_int(det) & (int)0x80000000);
- const float t = (u * a_kz + v * b_kz + w * c_kz) * sz;
- const float sign_t = xor_fl(t, sign_det);
- if ((sign_t < 0.0f)
- /* Differ from Cycles, don't read r_lambda's original value
- * otherwise we won't match any of the other intersect functions here...
- * which would be confusing. */
+
+ /* Calculate scaled z-coordinates of vertices and use them to calculate
+ * the hit distance.
+ */
+ const int sign_det = (float_as_int(det) & (int)0x80000000);
+ const float t = (u * a_kz + v * b_kz + w * c_kz) * sz;
+ const float sign_t = xor_fl(t, sign_det);
+ if ((sign_t < 0.0f)
+ /* Differ from Cycles, don't read r_lambda's original value
+ * otherwise we won't match any of the other intersect functions here...
+ * which would be confusing. */
#if 0
|| (sign_T > *r_lambda * xor_signmask(det, sign_mask))
#endif
- ) {
- return false;
- }
- else {
- /* Normalize u, v and t. */
- const float inv_det = 1.0f / det;
- if (r_uv) {
- r_uv[0] = u * inv_det;
- r_uv[1] = v * inv_det;
- }
- *r_lambda = t * inv_det;
- return true;
- }
+ ) {
+ return false;
+ }
+
+ /* Normalize u, v and t. */
+ const float inv_det = 1.0f / det;
+ if (r_uv) {
+ r_uv[0] = u * inv_det;
+ r_uv[1] = v * inv_det;
}
+ *r_lambda = t * inv_det;
+ return true;
}
bool isect_ray_tri_watertight_v3_simple(const float ray_origin[3],
@@ -2215,10 +2207,9 @@ bool isect_line_plane_v3(float r_isect_co[3],
madd_v3_v3v3fl(r_isect_co, l1, u, lambda);
return true;
}
- else {
- /* The segment is parallel to plane */
- return false;
- }
+
+ /* The segment is parallel to plane */
+ return false;
}
/**
@@ -2257,9 +2248,8 @@ bool isect_plane_plane_plane_v3(const float plane_a[4],
return true;
}
- else {
- return false;
- }
+
+ return false;
}
/**
@@ -2303,9 +2293,8 @@ bool isect_plane_plane_v3(const float plane_a[4],
return true;
}
- else {
- return false;
- }
+
+ return false;
}
/**
@@ -2436,65 +2425,54 @@ static bool isect_tri_tri_v2_impl_vert(const float t_a0[2],
if (line_point_side_v2(t_a0, t_b1, t_a1) <= 0.0f) {
return 1;
}
- else {
- return 0;
- }
+
+ return 0;
}
- else {
- if (line_point_side_v2(t_a0, t_b0, t_a2) >= 0.0f) {
- if (line_point_side_v2(t_a1, t_a2, t_b0) >= 0.0f) {
- return 1;
- }
- else {
- return 0;
- }
- }
- else {
- return 0;
+
+ if (line_point_side_v2(t_a0, t_b0, t_a2) >= 0.0f) {
+ if (line_point_side_v2(t_a1, t_a2, t_b0) >= 0.0f) {
+ return 1;
}
+
+ return 0;
}
+
+ return 0;
}
- else if (line_point_side_v2(t_a0, t_b1, t_a1) <= 0.0f) {
+ if (line_point_side_v2(t_a0, t_b1, t_a1) <= 0.0f) {
if (line_point_side_v2(t_b2, t_b1, t_a2) <= 0.0f) {
if (line_point_side_v2(t_a1, t_a2, t_b1) >= 0.0f) {
return 1;
}
- else {
- return 0;
- }
- }
- else {
+
return 0;
}
- }
- else {
+
return 0;
}
+
+ return 0;
}
- else if (line_point_side_v2(t_b2, t_b0, t_a2) >= 0.0f) {
+ if (line_point_side_v2(t_b2, t_b0, t_a2) >= 0.0f) {
if (line_point_side_v2(t_a1, t_a2, t_b2) >= 0.0f) {
if (line_point_side_v2(t_a0, t_b0, t_a2) >= 0.0f) {
return 1;
}
- else {
- return 0;
- }
+
+ return 0;
}
- else if (line_point_side_v2(t_a1, t_a2, t_b1) >= 0.0f) {
+ if (line_point_side_v2(t_a1, t_a2, t_b1) >= 0.0f) {
if (line_point_side_v2(t_b2, t_a2, t_b1) >= 0.0f) {
return 1;
}
- else {
- return 0;
- }
- }
- else {
+
return 0;
}
- }
- else {
+
return 0;
}
+
+ return 0;
}
static bool isect_tri_tri_v2_impl_edge(const float t_a0[2],
@@ -2511,47 +2489,38 @@ static bool isect_tri_tri_v2_impl_edge(const float t_a0[2],
if (line_point_side_v2(t_a0, t_a1, t_b2) >= 0.0f) {
return 1;
}
- else {
- return 0;
- }
+
+ return 0;
}
- else {
- if (line_point_side_v2(t_a1, t_a2, t_b0) >= 0.0f) {
- if (line_point_side_v2(t_a2, t_a0, t_b0) >= 0.0f) {
- return 1;
- }
- else {
- return 0;
- }
- }
- else {
- return 0;
+
+ if (line_point_side_v2(t_a1, t_a2, t_b0) >= 0.0f) {
+ if (line_point_side_v2(t_a2, t_a0, t_b0) >= 0.0f) {
+ return 1;
}
+
+ return 0;
}
+
+ return 0;
}
- else {
- if (line_point_side_v2(t_b2, t_b0, t_a2) >= 0.0f) {
- if (line_point_side_v2(t_a0, t_b0, t_a2) >= 0.0f) {
- if (line_point_side_v2(t_a0, t_a2, t_b2) >= 0.0f) {
- return 1;
- }
- else {
- if (line_point_side_v2(t_a1, t_a2, t_b2) >= 0.0f) {
- return 1;
- }
- else {
- return 0;
- }
- }
+
+ if (line_point_side_v2(t_b2, t_b0, t_a2) >= 0.0f) {
+ if (line_point_side_v2(t_a0, t_b0, t_a2) >= 0.0f) {
+ if (line_point_side_v2(t_a0, t_a2, t_b2) >= 0.0f) {
+ return 1;
}
- else {
- return 0;
+
+ if (line_point_side_v2(t_a1, t_a2, t_b2) >= 0.0f) {
+ return 1;
}
- }
- else {
+
return 0;
}
+
+ return 0;
}
+
+ return 0;
}
static int isect_tri_tri_impl_ccw_v2(const float t_a0[2],
@@ -2566,32 +2535,26 @@ static int isect_tri_tri_impl_ccw_v2(const float t_a0[2],
if (line_point_side_v2(t_b2, t_b0, t_a0) >= 0.0f) {
return 1;
}
- else {
- return isect_tri_tri_v2_impl_edge(t_a0, t_a1, t_a2, t_b0, t_b1, t_b2);
- }
+
+ return isect_tri_tri_v2_impl_edge(t_a0, t_a1, t_a2, t_b0, t_b1, t_b2);
}
- else {
- if (line_point_side_v2(t_b2, t_b0, t_a0) >= 0.0f) {
- return isect_tri_tri_v2_impl_edge(t_a0, t_a1, t_a2, t_b2, t_b0, t_b1);
- }
- else {
- return isect_tri_tri_v2_impl_vert(t_a0, t_a1, t_a2, t_b0, t_b1, t_b2);
- }
+
+ if (line_point_side_v2(t_b2, t_b0, t_a0) >= 0.0f) {
+ return isect_tri_tri_v2_impl_edge(t_a0, t_a1, t_a2, t_b2, t_b0, t_b1);
}
+
+ return isect_tri_tri_v2_impl_vert(t_a0, t_a1, t_a2, t_b0, t_b1, t_b2);
}
- else {
- if (line_point_side_v2(t_b1, t_b2, t_a0) >= 0.0f) {
- if (line_point_side_v2(t_b2, t_b0, t_a0) >= 0.0f) {
- return isect_tri_tri_v2_impl_edge(t_a0, t_a1, t_a2, t_b1, t_b2, t_b0);
- }
- else {
- return isect_tri_tri_v2_impl_vert(t_a0, t_a1, t_a2, t_b1, t_b2, t_b0);
- }
- }
- else {
- return isect_tri_tri_v2_impl_vert(t_a0, t_a1, t_a2, t_b2, t_b0, t_b1);
+
+ if (line_point_side_v2(t_b1, t_b2, t_a0) >= 0.0f) {
+ if (line_point_side_v2(t_b2, t_b0, t_a0) >= 0.0f) {
+ return isect_tri_tri_v2_impl_edge(t_a0, t_a1, t_a2, t_b1, t_b2, t_b0);
}
+
+ return isect_tri_tri_v2_impl_vert(t_a0, t_a1, t_a2, t_b1, t_b2, t_b0);
}
+
+ return isect_tri_tri_v2_impl_vert(t_a0, t_a1, t_a2, t_b2, t_b0, t_b1);
}
bool isect_tri_tri_v2(const float t_a0[2],
@@ -2605,18 +2568,15 @@ bool isect_tri_tri_v2(const float t_a0[2],
if (line_point_side_v2(t_b0, t_b1, t_b2) < 0.0f) {
return isect_tri_tri_impl_ccw_v2(t_a0, t_a2, t_a1, t_b0, t_b2, t_b1);
}
- else {
- return isect_tri_tri_impl_ccw_v2(t_a0, t_a2, t_a1, t_b0, t_b1, t_b2);
- }
+
+ return isect_tri_tri_impl_ccw_v2(t_a0, t_a2, t_a1, t_b0, t_b1, t_b2);
}
- else {
- if (line_point_side_v2(t_b0, t_b1, t_b2) < 0.0f) {
- return isect_tri_tri_impl_ccw_v2(t_a0, t_a1, t_a2, t_b0, t_b2, t_b1);
- }
- else {
- return isect_tri_tri_impl_ccw_v2(t_a0, t_a1, t_a2, t_b0, t_b1, t_b2);
- }
+
+ if (line_point_side_v2(t_b0, t_b1, t_b2) < 0.0f) {
+ return isect_tri_tri_impl_ccw_v2(t_a0, t_a1, t_a2, t_b0, t_b2, t_b1);
}
+
+ return isect_tri_tri_impl_ccw_v2(t_a0, t_a1, t_a2, t_b0, t_b1, t_b2);
}
/** \} */
@@ -2682,8 +2642,7 @@ int isect_aabb_planes_v3(const float (*planes)[4],
if (plane_point_side_v3(planes[i], bb_far) < 0.0f) {
return ISECT_AABB_PLANE_BEHIND_ANY;
}
- else if ((ret != ISECT_AABB_PLANE_CROSS_ANY) &&
- (plane_point_side_v3(planes[i], bb_near) < 0.0f)) {
+ if ((ret != ISECT_AABB_PLANE_CROSS_ANY) && (plane_point_side_v3(planes[i], bb_near) < 0.0f)) {
ret = ISECT_AABB_PLANE_CROSS_ANY;
}
}
@@ -2967,7 +2926,7 @@ int isect_line_line_epsilon_v3(const float v1[3],
return 0;
}
/* test if the two lines are coplanar */
- else if (UNLIKELY(fabsf(d) <= epsilon)) {
+ if (UNLIKELY(fabsf(d) <= epsilon)) {
cross_v3_v3v3(cb, c, b);
mul_v3_fl(a, dot_v3v3(cb, ab) / div);
@@ -2977,34 +2936,33 @@ int isect_line_line_epsilon_v3(const float v1[3],
return 1; /* one intersection only */
}
/* if not */
- else {
- float n[3], t[3];
- float v3t[3], v4t[3];
- sub_v3_v3v3(t, v1, v3);
- /* offset between both plane where the lines lies */
- cross_v3_v3v3(n, a, b);
- project_v3_v3v3(t, t, n);
+ float n[3], t[3];
+ float v3t[3], v4t[3];
+ sub_v3_v3v3(t, v1, v3);
- /* for the first line, offset the second line until it is coplanar */
- add_v3_v3v3(v3t, v3, t);
- add_v3_v3v3(v4t, v4, t);
+ /* offset between both plane where the lines lies */
+ cross_v3_v3v3(n, a, b);
+ project_v3_v3v3(t, t, n);
- sub_v3_v3v3(c, v3t, v1);
- sub_v3_v3v3(a, v2, v1);
- sub_v3_v3v3(b, v4t, v3t);
+ /* for the first line, offset the second line until it is coplanar */
+ add_v3_v3v3(v3t, v3, t);
+ add_v3_v3v3(v4t, v4, t);
- cross_v3_v3v3(ab, a, b);
- cross_v3_v3v3(cb, c, b);
+ sub_v3_v3v3(c, v3t, v1);
+ sub_v3_v3v3(a, v2, v1);
+ sub_v3_v3v3(b, v4t, v3t);
- mul_v3_fl(a, dot_v3v3(cb, ab) / dot_v3v3(ab, ab));
- add_v3_v3v3(r_i1, v1, a);
+ cross_v3_v3v3(ab, a, b);
+ cross_v3_v3v3(cb, c, b);
- /* for the second line, just subtract the offset from the first intersection point */
- sub_v3_v3v3(r_i2, r_i1, t);
+ mul_v3_fl(a, dot_v3v3(cb, ab) / dot_v3v3(ab, ab));
+ add_v3_v3v3(r_i1, v1, a);
- return 2; /* two nearest points */
- }
+ /* for the second line, just subtract the offset from the first intersection point */
+ sub_v3_v3v3(r_i2, r_i1, t);
+
+ return 2; /* two nearest points */
}
int isect_line_line_v3(const float v1[3],
@@ -3047,31 +3005,29 @@ bool isect_line_line_strict_v3(const float v1[3],
return false;
}
/* test if the two lines are coplanar */
- else if (UNLIKELY(fabsf(d) < epsilon)) {
+ if (UNLIKELY(fabsf(d) < epsilon)) {
return false;
}
- else {
- float f1, f2;
- cross_v3_v3v3(cb, c, b);
- cross_v3_v3v3(ca, c, a);
- f1 = dot_v3v3(cb, ab) / div;
- f2 = dot_v3v3(ca, ab) / div;
+ float f1, f2;
+ cross_v3_v3v3(cb, c, b);
+ cross_v3_v3v3(ca, c, a);
- if (f1 >= 0 && f1 <= 1 && f2 >= 0 && f2 <= 1) {
- mul_v3_fl(a, f1);
- add_v3_v3v3(vi, v1, a);
+ f1 = dot_v3v3(cb, ab) / div;
+ f2 = dot_v3v3(ca, ab) / div;
- if (r_lambda) {
- *r_lambda = f1;
- }
+ if (f1 >= 0 && f1 <= 1 && f2 >= 0 && f2 <= 1) {
+ mul_v3_fl(a, f1);
+ add_v3_v3v3(vi, v1, a);
- return true; /* intersection found */
- }
- else {
- return false;
+ if (r_lambda) {
+ *r_lambda = f1;
}
+
+ return true; /* intersection found */
}
+
+ return false;
}
/**
@@ -3237,15 +3193,14 @@ bool isect_ray_aabb_v3_simple(const float orig[3],
if ((hit_dist[1] < 0.0f || hit_dist[0] > hit_dist[1])) {
return false;
}
- else {
- if (tmin) {
- *tmin = hit_dist[0];
- }
- if (tmax) {
- *tmax = hit_dist[1];
- }
- return true;
+
+ if (tmin) {
+ *tmin = hit_dist[0];
+ }
+ if (tmax) {
+ *tmax = hit_dist[1];
}
+ return true;
}
float closest_to_ray_v3(float r_close[3],
@@ -3522,9 +3477,8 @@ bool isect_point_tri_v3(
return true;
}
- else {
- return false;
- }
+
+ return false;
}
bool clip_segment_v3_plane(
@@ -3547,7 +3501,7 @@ bool clip_segment_v3_plane(
if (t >= div) {
return false;
}
- else if (t > 0.0f) {
+ if (t > 0.0f) {
const float p1_copy[3] = {UNPACK3(p1)};
copy_v3_v3(r_p2, p2);
madd_v3_v3v3fl(r_p1, p1_copy, dp, t / div);
@@ -3559,7 +3513,7 @@ bool clip_segment_v3_plane(
if (t >= 0.0f) {
return false;
}
- else if (t > div) {
+ if (t > div) {
const float p1_copy[3] = {UNPACK3(p1)};
copy_v3_v3(r_p1, p1);
madd_v3_v3v3fl(r_p2, p1_copy, dp, t / div);
@@ -3598,7 +3552,7 @@ bool clip_segment_v3_plane_n(const float p1[3],
if (t >= div) {
return false;
}
- else if (t > 0.0f) {
+ if (t > 0.0f) {
t /= div;
if (t > p1_fac) {
p1_fac = t;
@@ -3613,7 +3567,7 @@ bool clip_segment_v3_plane_n(const float p1[3],
if (t >= 0.0f) {
return false;
}
- else if (t > div) {
+ if (t > div) {
t /= div;
if (t < p2_fac) {
p2_fac = t;
@@ -3797,8 +3751,8 @@ int barycentric_inside_triangle_v2(const float w[3])
if (IN_RANGE(w[0], 0.0f, 1.0f) && IN_RANGE(w[1], 0.0f, 1.0f) && IN_RANGE(w[2], 0.0f, 1.0f)) {
return 1;
}
- else if (IN_RANGE_INCL(w[0], 0.0f, 1.0f) && IN_RANGE_INCL(w[1], 0.0f, 1.0f) &&
- IN_RANGE_INCL(w[2], 0.0f, 1.0f)) {
+ if (IN_RANGE_INCL(w[0], 0.0f, 1.0f) && IN_RANGE_INCL(w[1], 0.0f, 1.0f) &&
+ IN_RANGE_INCL(w[2], 0.0f, 1.0f)) {
return 2;
}
@@ -4095,68 +4049,67 @@ int interp_sparse_array(float *array, const int list_size, const float skipval)
if (found_valid == 0) {
return -1;
}
- else if (found_invalid == 0) {
+ if (found_invalid == 0) {
return 0;
}
- else {
- /* found invalid depths, interpolate */
- float valid_last = skipval;
- int valid_ofs = 0;
- float *array_up = MEM_callocN(sizeof(float) * (size_t)list_size, "interp_sparse_array up");
- float *array_down = MEM_callocN(sizeof(float) * (size_t)list_size, "interp_sparse_array up");
+ /* found invalid depths, interpolate */
+ float valid_last = skipval;
+ int valid_ofs = 0;
- int *ofs_tot_up = MEM_callocN(sizeof(int) * (size_t)list_size, "interp_sparse_array tup");
- int *ofs_tot_down = MEM_callocN(sizeof(int) * (size_t)list_size, "interp_sparse_array tdown");
+ float *array_up = MEM_callocN(sizeof(float) * (size_t)list_size, "interp_sparse_array up");
+ float *array_down = MEM_callocN(sizeof(float) * (size_t)list_size, "interp_sparse_array up");
- for (i = 0; i < list_size; i++) {
- if (array[i] == skipval) {
- array_up[i] = valid_last;
- ofs_tot_up[i] = ++valid_ofs;
- }
- else {
- valid_last = array[i];
- valid_ofs = 0;
- }
+ int *ofs_tot_up = MEM_callocN(sizeof(int) * (size_t)list_size, "interp_sparse_array tup");
+ int *ofs_tot_down = MEM_callocN(sizeof(int) * (size_t)list_size, "interp_sparse_array tdown");
+
+ for (i = 0; i < list_size; i++) {
+ if (array[i] == skipval) {
+ array_up[i] = valid_last;
+ ofs_tot_up[i] = ++valid_ofs;
+ }
+ else {
+ valid_last = array[i];
+ valid_ofs = 0;
}
+ }
- valid_last = skipval;
- valid_ofs = 0;
+ valid_last = skipval;
+ valid_ofs = 0;
- for (i = list_size - 1; i >= 0; i--) {
- if (array[i] == skipval) {
- array_down[i] = valid_last;
- ofs_tot_down[i] = ++valid_ofs;
- }
- else {
- valid_last = array[i];
- valid_ofs = 0;
- }
+ for (i = list_size - 1; i >= 0; i--) {
+ if (array[i] == skipval) {
+ array_down[i] = valid_last;
+ ofs_tot_down[i] = ++valid_ofs;
+ }
+ else {
+ valid_last = array[i];
+ valid_ofs = 0;
}
+ }
- /* now blend */
- for (i = 0; i < list_size; i++) {
- if (array[i] == skipval) {
- if (array_up[i] != skipval && array_down[i] != skipval) {
- array[i] = ((array_up[i] * (float)ofs_tot_down[i]) +
- (array_down[i] * (float)ofs_tot_up[i])) /
- (float)(ofs_tot_down[i] + ofs_tot_up[i]);
- }
- else if (array_up[i] != skipval) {
- array[i] = array_up[i];
- }
- else if (array_down[i] != skipval) {
- array[i] = array_down[i];
- }
+ /* now blend */
+ for (i = 0; i < list_size; i++) {
+ if (array[i] == skipval) {
+ if (array_up[i] != skipval && array_down[i] != skipval) {
+ array[i] = ((array_up[i] * (float)ofs_tot_down[i]) +
+ (array_down[i] * (float)ofs_tot_up[i])) /
+ (float)(ofs_tot_down[i] + ofs_tot_up[i]);
+ }
+ else if (array_up[i] != skipval) {
+ array[i] = array_up[i];
+ }
+ else if (array_down[i] != skipval) {
+ array[i] = array_down[i];
}
}
+ }
- MEM_freeN(array_up);
- MEM_freeN(array_down);
+ MEM_freeN(array_up);
+ MEM_freeN(array_down);
- MEM_freeN(ofs_tot_up);
- MEM_freeN(ofs_tot_down);
- }
+ MEM_freeN(ofs_tot_up);
+ MEM_freeN(ofs_tot_down);
return 1;
}
@@ -4279,7 +4232,7 @@ void interp_weights_poly_v3(float *w, float v[][3], const int n, const float co[
ix_flag = IS_POINT_IX;
break;
}
- else if (UNLIKELY(dist_squared_to_line_segment_v3(co, v_curr, v_next) < eps_sq)) {
+ if (UNLIKELY(dist_squared_to_line_segment_v3(co, v_curr, v_next) < eps_sq)) {
ix_flag = IS_SEGMENT_IX;
break;
}
@@ -4364,7 +4317,7 @@ void interp_weights_poly_v2(float *w, float v[][2], const int n, const float co[
ix_flag = IS_POINT_IX;
break;
}
- else if (UNLIKELY(dist_squared_to_line_segment_v2(co, v_curr, v_next) < eps_sq)) {
+ if (UNLIKELY(dist_squared_to_line_segment_v2(co, v_curr, v_next) < eps_sq)) {
ix_flag = IS_SEGMENT_IX;
break;
}
@@ -4647,17 +4600,15 @@ float resolve_quad_u_v2(const float st[2],
if (IS_ZERO(fDen) == 0) {
return (float)(a / fDen);
}
- else {
- return 0.0f;
- }
- }
- else {
- const double desc_sq = b * b - a * fC;
- const double desc = sqrt(desc_sq < 0.0 ? 0.0 : desc_sq);
- const double s = signed_area > 0 ? (-1.0) : 1.0;
- return (float)(((a - b) + s * desc) / denom);
+ return 0.0f;
}
+
+ const double desc_sq = b * b - a * fC;
+ const double desc = sqrt(desc_sq < 0.0 ? 0.0 : desc_sq);
+ const double s = signed_area > 0 ? (-1.0) : 1.0;
+
+ return (float)(((a - b) + s * desc) / denom);
}
#undef IS_ZERO
@@ -6139,17 +6090,16 @@ float cubic_tangent_factor_circle_v3(const float tan_l[3], const float tan_r[3])
/* no angle difference (use fallback, length wont make any difference) */
return (1.0f / 3.0f) * 0.75f;
}
- else if (tan_dot < -1.0f + eps) {
+ if (tan_dot < -1.0f + eps) {
/* parallele tangents (half-circle) */
return (1.0f / 2.0f);
}
- else {
- /* non-aligned tangents, calculate handle length */
- const float angle = acosf(tan_dot) / 2.0f;
- /* could also use 'angle_sin = len_vnvn(tan_l, tan_r, dims) / 2.0' */
- const float angle_sin = sinf(angle);
- const float angle_cos = cosf(angle);
- return ((1.0f - angle_cos) / (angle_sin * 2.0f)) / angle_sin;
- }
+ /* non-aligned tangents, calculate handle length */
+ const float angle = acosf(tan_dot) / 2.0f;
+
+ /* could also use 'angle_sin = len_vnvn(tan_l, tan_r, dims) / 2.0' */
+ const float angle_sin = sinf(angle);
+ const float angle_cos = cosf(angle);
+ return ((1.0f - angle_cos) / (angle_sin * 2.0f)) / angle_sin;
}
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index a2f7cc24dd3..a6368981050 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -644,9 +644,8 @@ float angle_signed_normalized_qt(const float q[4])
if (q[0] >= 0.0f) {
return 2.0f * saacos(q[0]);
}
- else {
- return -2.0f * saacos(-q[0]);
- }
+
+ return -2.0f * saacos(-q[0]);
}
float angle_signed_normalized_qtqt(const float q1[4], const float q2[4])
@@ -654,11 +653,10 @@ float angle_signed_normalized_qtqt(const float q1[4], const float q2[4])
if (dot_qtqt(q1, q2) >= 0.0f) {
return angle_normalized_qtqt(q1, q2);
}
- else {
- float q2_copy[4];
- negate_v4_v4(q2_copy, q2);
- return -angle_normalized_qtqt(q1, q2_copy);
- }
+
+ float q2_copy[4];
+ negate_v4_v4(q2_copy, q2);
+ return -angle_normalized_qtqt(q1, q2_copy);
}
float angle_signed_qt(const float q[4])
@@ -675,11 +673,10 @@ float angle_signed_qtqt(const float q1[4], const float q2[4])
if (dot_qtqt(q1, q2) >= 0.0f) {
return angle_qtqt(q1, q2);
}
- else {
- float q2_copy[4];
- negate_v4_v4(q2_copy, q2);
- return -angle_qtqt(q1, q2_copy);
- }
+
+ float q2_copy[4];
+ negate_v4_v4(q2_copy, q2);
+ return -angle_qtqt(q1, q2_copy);
}
/** \} */
@@ -1594,12 +1591,11 @@ static const RotOrderInfo *get_rotation_order_info(const short order)
if (order < 1) {
return &rotOrders[0];
}
- else if (order < 6) {
+ if (order < 6) {
return &rotOrders[order - 1];
}
- else {
- return &rotOrders[5];
- }
+
+ return &rotOrders[5];
}
/* Construct quaternion from Euler angles (in radians). */
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index 7f1840228e2..909d508e262 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -506,11 +506,10 @@ float angle_normalized_v3v3(const float v1[3], const float v2[3])
if (dot_v3v3(v1, v2) >= 0.0f) {
return 2.0f * saasin(len_v3v3(v1, v2) / 2.0f);
}
- else {
- float v2_n[3];
- negate_v3_v3(v2_n, v2);
- return (float)M_PI - 2.0f * saasin(len_v3v3(v1, v2_n) / 2.0f);
- }
+
+ float v2_n[3];
+ negate_v3_v3(v2_n, v2);
+ return (float)M_PI - 2.0f * saasin(len_v3v3(v1, v2_n) / 2.0f);
}
float angle_normalized_v2v2(const float v1[2], const float v2[2])
@@ -523,11 +522,10 @@ float angle_normalized_v2v2(const float v1[2], const float v2[2])
if (dot_v2v2(v1, v2) >= 0.0f) {
return 2.0f * saasin(len_v2v2(v1, v2) / 2.0f);
}
- else {
- float v2_n[2];
- negate_v2_v2(v2_n, v2);
- return (float)M_PI - 2.0f * saasin(len_v2v2(v1, v2_n) / 2.0f);
- }
+
+ float v2_n[2];
+ negate_v2_v2(v2_n, v2);
+ return (float)M_PI - 2.0f * saasin(len_v2v2(v1, v2_n) / 2.0f);
}
/**
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index d912cb8d464..67d41ffb779 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -427,9 +427,8 @@ static int BLI_path_unc_prefix_len(const char *path)
/* we assume long UNC path like \\?\server\share\folder etc... */
return 4;
}
- else {
- return 2;
- }
+
+ return 2;
}
return 0;
@@ -683,7 +682,7 @@ bool BLI_path_suffix(char *string, size_t maxlen, const char *suffix, const char
has_extension = true;
break;
}
- else if (ELEM(string[a], '/', '\\')) {
+ if (ELEM(string[a], '/', '\\')) {
break;
}
}
@@ -713,9 +712,8 @@ bool BLI_path_parent_dir(char *path)
strcpy(path, tmp); /* We assume pardir is always shorter... */
return true;
}
- else {
- return false;
- }
+
+ return false;
}
/**
@@ -764,11 +762,10 @@ static bool stringframe_chars(const char *path, int *char_start, int *char_end)
*char_end = ch_end;
return true;
}
- else {
- *char_start = -1;
- *char_end = -1;
- return false;
- }
+
+ *char_start = -1;
+ *char_end = -1;
+ return false;
}
/**
@@ -1731,9 +1728,8 @@ void BLI_join_dirfile(char *__restrict dst,
dst[dirlen - 1] = '\0';
return; /* dir fills the path */
}
- else {
- memcpy(dst, dir, dirlen + 1);
- }
+
+ memcpy(dst, dir, dirlen + 1);
if (dirlen + 1 >= maxlen) {
return; /* fills the path */
@@ -1891,32 +1887,31 @@ bool BLI_path_name_at_index(const char *__restrict path,
}
return false;
}
- else {
- /* negative number, reverse where -1 is the last element */
- int index_step = -1;
- int prev = strlen(path);
- int i = prev - 1;
- while (true) {
- const char c = i >= 0 ? path[i] : '\0';
- if (ELEM(c, SEP, ALTSEP, '\0')) {
- if (prev - 1 != i) {
- i += 1;
- if (index_step == index) {
- *r_offset = i;
- *r_len = prev - i;
- return true;
- }
- index_step -= 1;
- }
- if (c == '\0') {
- break;
+
+ /* negative number, reverse where -1 is the last element */
+ int index_step = -1;
+ int prev = strlen(path);
+ int i = prev - 1;
+ while (true) {
+ const char c = i >= 0 ? path[i] : '\0';
+ if (ELEM(c, SEP, ALTSEP, '\0')) {
+ if (prev - 1 != i) {
+ i += 1;
+ if (index_step == index) {
+ *r_offset = i;
+ *r_len = prev - i;
+ return true;
}
- prev = i;
+ index_step -= 1;
}
- i -= 1;
+ if (c == '\0') {
+ break;
+ }
+ prev = i;
}
- return false;
+ i -= 1;
}
+ return false;
}
/**
@@ -1930,7 +1925,7 @@ const char *BLI_path_slash_find(const char *string)
if (!ffslash) {
return fbslash;
}
- else if (!fbslash) {
+ if (!fbslash) {
return ffslash;
}
@@ -1948,7 +1943,7 @@ const char *BLI_path_slash_rfind(const char *string)
if (!lfslash) {
return lbslash;
}
- else if (!lbslash) {
+ if (!lbslash) {
return lfslash;
}
diff --git a/source/blender/blenlib/intern/polyfill_2d.c b/source/blender/blenlib/intern/polyfill_2d.c
index 90a4a4f4c2d..d1e2bd58909 100644
--- a/source/blender/blenlib/intern/polyfill_2d.c
+++ b/source/blender/blenlib/intern/polyfill_2d.c
@@ -177,12 +177,11 @@ BLI_INLINE eSign signum_enum(float a)
if (UNLIKELY(a == 0.0f)) {
return 0;
}
- else if (a > 0.0f) {
+ if (a > 0.0f) {
return 1;
}
- else {
- return -1;
- }
+
+ return -1;
}
/**
@@ -250,7 +249,7 @@ static uint kdtree2d_balance_recursive(
if (totnode <= 0) {
return KDNODE_UNSET;
}
- else if (totnode == 1) {
+ if (totnode == 1) {
return 0 + ofs;
}
@@ -330,9 +329,8 @@ static void kdtree2d_node_remove(struct KDTree2D *tree, uint index)
if (node_index == KDNODE_UNSET) {
return;
}
- else {
- tree->nodes_map[index] = KDNODE_UNSET;
- }
+
+ tree->nodes_map[index] = KDNODE_UNSET;
node = &tree->nodes[node_index];
tree->totnode -= 1;
diff --git a/source/blender/blenlib/intern/polyfill_2d_beautify.c b/source/blender/blenlib/intern/polyfill_2d_beautify.c
index 41364c5a3a9..7bfca149ffb 100644
--- a/source/blender/blenlib/intern/polyfill_2d_beautify.c
+++ b/source/blender/blenlib/intern/polyfill_2d_beautify.c
@@ -64,14 +64,14 @@ static int oedge_cmp(const void *a1, const void *a2)
if (x1->verts[0] > x2->verts[0]) {
return 1;
}
- else if (x1->verts[0] < x2->verts[0]) {
+ if (x1->verts[0] < x2->verts[0]) {
return -1;
}
if (x1->verts[1] > x2->verts[1]) {
return 1;
}
- else if (x1->verts[1] < x2->verts[1]) {
+ if (x1->verts[1] < x2->verts[1]) {
return -1;
}
@@ -79,7 +79,7 @@ static int oedge_cmp(const void *a1, const void *a2)
if (x1->e_half > x2->e_half) {
return 1;
}
- else if (x1->e_half < x2->e_half) {
+ if (x1->e_half < x2->e_half) {
return -1;
}
/* Should never get here, no two edges should be the same. */
@@ -141,7 +141,7 @@ float BLI_polyfill_beautify_quad_rotate_calc_ex(const float v1[2],
if ((area_2x_123 >= 0.0f) != (area_2x_134 >= 0.0f)) {
break;
}
- else if ((fabsf(area_2x_123) <= eps_zero_area) || (fabsf(area_2x_134) <= eps_zero_area)) {
+ if ((fabsf(area_2x_123) <= eps_zero_area) || (fabsf(area_2x_134) <= eps_zero_area)) {
break;
}
@@ -150,11 +150,10 @@ float BLI_polyfill_beautify_quad_rotate_calc_ex(const float v1[2],
if (lock_degenerate) {
break;
}
- else {
- return -FLT_MAX; /* always rotate */
- }
+
+ return -FLT_MAX; /* always rotate */
}
- else if ((fabsf(area_2x_234) <= eps_zero_area) || (fabsf(area_2x_241) <= eps_zero_area)) {
+ if ((fabsf(area_2x_234) <= eps_zero_area) || (fabsf(area_2x_241) <= eps_zero_area)) {
return -FLT_MAX; /* always rotate */
}
diff --git a/source/blender/blenlib/intern/quadric.c b/source/blender/blenlib/intern/quadric.c
index 3ad1844cfe1..ac522171951 100644
--- a/source/blender/blenlib/intern/quadric.c
+++ b/source/blender/blenlib/intern/quadric.c
@@ -107,9 +107,8 @@ static bool quadric_to_tensor_m3_inverse(const Quadric *q, double m[3][3], doubl
return true;
}
- else {
- return false;
- }
+
+ return false;
}
void BLI_quadric_to_vector_v3(const Quadric *q, double v[3])
@@ -161,7 +160,6 @@ bool BLI_quadric_optimize(const Quadric *q, double v[3], const double epsilon)
negate_v3_db(v);
return true;
}
- else {
- return false;
- }
+
+ return false;
}
diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c
index bf3c8730b01..f952b62cb61 100644
--- a/source/blender/blenlib/intern/rct.c
+++ b/source/blender/blenlib/intern/rct.c
@@ -238,15 +238,14 @@ static int isect_segments_i(const int v1[2], const int v2[2], const int v3[2], c
if (div == 0.0) {
return 1; /* co-linear */
}
- else {
- const double lambda = (double)((v1[1] - v3[1]) * (v4[0] - v3[0]) -
- (v1[0] - v3[0]) * (v4[1] - v3[1])) /
- div;
- const double mu = (double)((v1[1] - v3[1]) * (v2[0] - v1[0]) -
- (v1[0] - v3[0]) * (v2[1] - v1[1])) /
- div;
- return (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0);
- }
+
+ const double lambda = (double)((v1[1] - v3[1]) * (v4[0] - v3[0]) -
+ (v1[0] - v3[0]) * (v4[1] - v3[1])) /
+ div;
+ const double mu = (double)((v1[1] - v3[1]) * (v2[0] - v1[0]) -
+ (v1[0] - v3[0]) * (v2[1] - v1[1])) /
+ div;
+ return (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0);
}
static int isect_segments_fl(const float v1[2],
const float v2[2],
@@ -258,15 +257,14 @@ static int isect_segments_fl(const float v1[2],
if (div == 0.0) {
return 1; /* co-linear */
}
- else {
- const double lambda = (double)((v1[1] - v3[1]) * (v4[0] - v3[0]) -
- (v1[0] - v3[0]) * (v4[1] - v3[1])) /
- div;
- const double mu = (double)((v1[1] - v3[1]) * (v2[0] - v1[0]) -
- (v1[0] - v3[0]) * (v2[1] - v1[1])) /
- div;
- return (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0);
- }
+
+ const double lambda = (double)((v1[1] - v3[1]) * (v4[0] - v3[0]) -
+ (v1[0] - v3[0]) * (v4[1] - v3[1])) /
+ div;
+ const double mu = (double)((v1[1] - v3[1]) * (v2[0] - v1[0]) -
+ (v1[0] - v3[0]) * (v2[1] - v1[1])) /
+ div;
+ return (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0);
}
bool BLI_rcti_isect_segment(const rcti *rect, const int s1[2], const int s2[2])
@@ -289,31 +287,30 @@ bool BLI_rcti_isect_segment(const rcti *rect, const int s1[2], const int s2[2])
if (BLI_rcti_isect_pt_v(rect, s1) || BLI_rcti_isect_pt_v(rect, s2)) {
return true;
}
- else {
- /* both points are outside but may intersect the rect */
- int tvec1[2];
- int tvec2[2];
- /* diagonal: [/] */
- tvec1[0] = rect->xmin;
- tvec1[1] = rect->ymin;
- tvec2[0] = rect->xmin;
- tvec2[1] = rect->ymax;
- if (isect_segments_i(s1, s2, tvec1, tvec2)) {
- return true;
- }
- /* diagonal: [\] */
- tvec1[0] = rect->xmin;
- tvec1[1] = rect->ymax;
- tvec2[0] = rect->xmax;
- tvec2[1] = rect->ymin;
- if (isect_segments_i(s1, s2, tvec1, tvec2)) {
- return true;
- }
+ /* both points are outside but may intersect the rect */
+ int tvec1[2];
+ int tvec2[2];
+ /* diagonal: [/] */
+ tvec1[0] = rect->xmin;
+ tvec1[1] = rect->ymin;
+ tvec2[0] = rect->xmin;
+ tvec2[1] = rect->ymax;
+ if (isect_segments_i(s1, s2, tvec1, tvec2)) {
+ return true;
+ }
- /* no intersection */
- return false;
+ /* diagonal: [\] */
+ tvec1[0] = rect->xmin;
+ tvec1[1] = rect->ymax;
+ tvec2[0] = rect->xmax;
+ tvec2[1] = rect->ymin;
+ if (isect_segments_i(s1, s2, tvec1, tvec2)) {
+ return true;
}
+
+ /* no intersection */
+ return false;
}
bool BLI_rctf_isect_segment(const rctf *rect, const float s1[2], const float s2[2])
@@ -336,31 +333,30 @@ bool BLI_rctf_isect_segment(const rctf *rect, const float s1[2], const float s2[
if (BLI_rctf_isect_pt_v(rect, s1) || BLI_rctf_isect_pt_v(rect, s2)) {
return true;
}
- else {
- /* both points are outside but may intersect the rect */
- float tvec1[2];
- float tvec2[2];
- /* diagonal: [/] */
- tvec1[0] = rect->xmin;
- tvec1[1] = rect->ymin;
- tvec2[0] = rect->xmin;
- tvec2[1] = rect->ymax;
- if (isect_segments_fl(s1, s2, tvec1, tvec2)) {
- return true;
- }
- /* diagonal: [\] */
- tvec1[0] = rect->xmin;
- tvec1[1] = rect->ymax;
- tvec2[0] = rect->xmax;
- tvec2[1] = rect->ymin;
- if (isect_segments_fl(s1, s2, tvec1, tvec2)) {
- return true;
- }
+ /* both points are outside but may intersect the rect */
+ float tvec1[2];
+ float tvec2[2];
+ /* diagonal: [/] */
+ tvec1[0] = rect->xmin;
+ tvec1[1] = rect->ymin;
+ tvec2[0] = rect->xmin;
+ tvec2[1] = rect->ymax;
+ if (isect_segments_fl(s1, s2, tvec1, tvec2)) {
+ return true;
+ }
- /* no intersection */
- return false;
+ /* diagonal: [\] */
+ tvec1[0] = rect->xmin;
+ tvec1[1] = rect->ymax;
+ tvec2[0] = rect->xmax;
+ tvec2[1] = rect->ymin;
+ if (isect_segments_fl(s1, s2, tvec1, tvec2)) {
+ return true;
}
+
+ /* no intersection */
+ return false;
}
bool BLI_rcti_isect_circle(const rcti *rect, const float xy[2], const float radius)
@@ -890,15 +886,14 @@ bool BLI_rctf_isect(const rctf *src1, const rctf *src2, rctf *dest)
}
return true;
}
- else {
- if (dest) {
- dest->xmin = 0;
- dest->xmax = 0;
- dest->ymin = 0;
- dest->ymax = 0;
- }
- return false;
+
+ if (dest) {
+ dest->xmin = 0;
+ dest->xmax = 0;
+ dest->ymin = 0;
+ dest->ymax = 0;
}
+ return false;
}
bool BLI_rcti_isect(const rcti *src1, const rcti *src2, rcti *dest)
@@ -920,15 +915,14 @@ bool BLI_rcti_isect(const rcti *src1, const rcti *src2, rcti *dest)
}
return true;
}
- else {
- if (dest) {
- dest->xmin = 0;
- dest->xmax = 0;
- dest->ymin = 0;
- dest->ymax = 0;
- }
- return false;
+
+ if (dest) {
+ dest->xmin = 0;
+ dest->xmax = 0;
+ dest->ymin = 0;
+ dest->ymax = 0;
}
+ return false;
}
bool BLI_rctf_isect_rect_x(const rctf *src1, const rctf *src2, float range_x[2])
@@ -943,13 +937,12 @@ bool BLI_rctf_isect_rect_x(const rctf *src1, const rctf *src2, float range_x[2])
}
return true;
}
- else {
- if (range_x) {
- range_x[0] = 0;
- range_x[1] = 0;
- }
- return false;
+
+ if (range_x) {
+ range_x[0] = 0;
+ range_x[1] = 0;
}
+ return false;
}
bool BLI_rctf_isect_rect_y(const rctf *src1, const rctf *src2, float range_y[2])
@@ -964,13 +957,12 @@ bool BLI_rctf_isect_rect_y(const rctf *src1, const rctf *src2, float range_y[2])
}
return true;
}
- else {
- if (range_y) {
- range_y[0] = 0;
- range_y[1] = 0;
- }
- return false;
+
+ if (range_y) {
+ range_y[0] = 0;
+ range_y[1] = 0;
}
+ return false;
}
bool BLI_rcti_isect_rect_x(const rcti *src1, const rcti *src2, int range_x[2])
@@ -985,13 +977,12 @@ bool BLI_rcti_isect_rect_x(const rcti *src1, const rcti *src2, int range_x[2])
}
return true;
}
- else {
- if (range_x) {
- range_x[0] = 0;
- range_x[1] = 0;
- }
- return false;
+
+ if (range_x) {
+ range_x[0] = 0;
+ range_x[1] = 0;
}
+ return false;
}
bool BLI_rcti_isect_rect_y(const rcti *src1, const rcti *src2, int range_y[2])
@@ -1006,13 +997,12 @@ bool BLI_rcti_isect_rect_y(const rcti *src1, const rcti *src2, int range_y[2])
}
return true;
}
- else {
- if (range_y) {
- range_y[0] = 0;
- range_y[1] = 0;
- }
- return false;
+
+ if (range_y) {
+ range_y[0] = 0;
+ range_y[1] = 0;
}
+ return false;
}
void BLI_rcti_rctf_copy(rcti *dst, const rctf *src)
diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c
index 4723a3532ac..8b536354af2 100644
--- a/source/blender/blenlib/intern/scanfill.c
+++ b/source/blender/blenlib/intern/scanfill.c
@@ -91,13 +91,13 @@ static int vergscdata(const void *a1, const void *a2)
if (x1->vert->xy[1] < x2->vert->xy[1]) {
return 1;
}
- else if (x1->vert->xy[1] > x2->vert->xy[1]) {
+ if (x1->vert->xy[1] > x2->vert->xy[1]) {
return -1;
}
- else if (x1->vert->xy[0] > x2->vert->xy[0]) {
+ if (x1->vert->xy[0] > x2->vert->xy[0]) {
return 1;
}
- else if (x1->vert->xy[0] < x2->vert->xy[0]) {
+ if (x1->vert->xy[0] < x2->vert->xy[0]) {
return -1;
}
@@ -111,13 +111,13 @@ static int vergpoly(const void *a1, const void *a2)
if (x1->min_xy[0] > x2->min_xy[0]) {
return 1;
}
- else if (x1->min_xy[0] < x2->min_xy[0]) {
+ if (x1->min_xy[0] < x2->min_xy[0]) {
return -1;
}
- else if (x1->min_xy[1] > x2->min_xy[1]) {
+ if (x1->min_xy[1] > x2->min_xy[1]) {
return 1;
}
- else if (x1->min_xy[1] < x2->min_xy[1]) {
+ if (x1->min_xy[1] < x2->min_xy[1]) {
return -1;
}
@@ -259,7 +259,7 @@ static bool testedgeside(const float v1[2], const float v2[2], const float v3[2]
if (inp < 0.0f) {
return false;
}
- else if (inp == 0.0f) {
+ if (inp == 0.0f) {
if (v1[0] == v3[0] && v1[1] == v3[1]) {
return false;
}
@@ -417,25 +417,24 @@ static void testvertexnearedge(ScanFillContext *sf_ctx)
eve->edge_tot = 0;
break;
}
- else if (compare_v2v2(eve->xy, eed->v2->xy, SF_EPSILON)) {
+ if (compare_v2v2(eve->xy, eed->v2->xy, SF_EPSILON)) {
ed1->v2 = eed->v2;
eed->v2->edge_tot++;
eve->edge_tot = 0;
break;
}
- else {
- if (boundinsideEV(eed, eve)) {
- const float dist = dist_squared_to_line_v2(eed->v1->xy, eed->v2->xy, eve->xy);
- if (dist < SF_EPSILON_SQ) {
- /* new edge */
- ed1 = BLI_scanfill_edge_add(sf_ctx, eed->v1, eve);
-
- /* printf("fill: vertex near edge %x\n", eve); */
- ed1->poly_nr = eed->poly_nr;
- eed->v1 = eve;
- eve->edge_tot = 3;
- break;
- }
+
+ if (boundinsideEV(eed, eve)) {
+ const float dist = dist_squared_to_line_v2(eed->v1->xy, eed->v2->xy, eve->xy);
+ if (dist < SF_EPSILON_SQ) {
+ /* new edge */
+ ed1 = BLI_scanfill_edge_add(sf_ctx, eed->v1, eve);
+
+ /* printf("fill: vertex near edge %x\n", eve); */
+ ed1->poly_nr = eed->poly_nr;
+ eed->v1 = eve;
+ eve->edge_tot = 3;
+ break;
}
}
}
@@ -875,41 +874,40 @@ unsigned int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const
if (UNLIKELY(eve == NULL)) {
return 0;
}
+
+ float n[3];
+
+ if (nor_proj) {
+ copy_v3_v3(n, nor_proj);
+ }
else {
- float n[3];
+ /* define projection: with 'best' normal */
+ /* Newell's Method */
+ /* Similar code used elsewhere, but this checks for double ups
+ * which historically this function supports so better not change */
- if (nor_proj) {
- copy_v3_v3(n, nor_proj);
- }
- else {
- /* define projection: with 'best' normal */
- /* Newell's Method */
- /* Similar code used elsewhere, but this checks for double ups
- * which historically this function supports so better not change */
-
- /* warning: this only gives stable direction with single polygons,
- * ideally we'd calculate connectivity and each polys normal, see T41047 */
- const float *v_prev;
-
- zero_v3(n);
- eve = sf_ctx->fillvertbase.last;
- v_prev = eve->co;
-
- for (eve = sf_ctx->fillvertbase.first; eve; eve = eve->next) {
- if (LIKELY(!compare_v3v3(v_prev, eve->co, SF_EPSILON))) {
- add_newell_cross_v3_v3v3(n, v_prev, eve->co);
- v_prev = eve->co;
- }
- }
- }
+ /* warning: this only gives stable direction with single polygons,
+ * ideally we'd calculate connectivity and each polys normal, see T41047 */
+ const float *v_prev;
- if (UNLIKELY(normalize_v3(n) == 0.0f)) {
- return 0;
+ zero_v3(n);
+ eve = sf_ctx->fillvertbase.last;
+ v_prev = eve->co;
+
+ for (eve = sf_ctx->fillvertbase.first; eve; eve = eve->next) {
+ if (LIKELY(!compare_v3v3(v_prev, eve->co, SF_EPSILON))) {
+ add_newell_cross_v3_v3v3(n, v_prev, eve->co);
+ v_prev = eve->co;
+ }
}
+ }
- axis_dominant_v3_to_m3_negate(mat_2d, n);
+ if (UNLIKELY(normalize_v3(n) == 0.0f)) {
+ return 0;
}
+ axis_dominant_v3_to_m3_negate(mat_2d, n);
+
/* STEP 1: COUNT POLYS */
if (sf_ctx->poly_nr != SF_POLY_UNSET) {
poly = (unsigned short)(sf_ctx->poly_nr + 1);
diff --git a/source/blender/blenlib/intern/scanfill_utils.c b/source/blender/blenlib/intern/scanfill_utils.c
index 31b2bf85142..660d3dca807 100644
--- a/source/blender/blenlib/intern/scanfill_utils.c
+++ b/source/blender/blenlib/intern/scanfill_utils.c
@@ -139,9 +139,8 @@ static int edge_isect_ls_sort_cb(void *thunk, const void *def_a_ptr, const void
if (a > b) {
return -1;
}
- else {
- return (a < b);
- }
+
+ return (a < b);
}
static ScanFillEdge *edge_step(PolyInfo *poly_info,
diff --git a/source/blender/blenlib/intern/smallhash.c b/source/blender/blenlib/intern/smallhash.c
index 6d1ce3c84cd..ab2b0fd2928 100644
--- a/source/blender/blenlib/intern/smallhash.c
+++ b/source/blender/blenlib/intern/smallhash.c
@@ -253,10 +253,9 @@ bool BLI_smallhash_reinsert(SmallHash *sh, uintptr_t key, void *item)
e->val = item;
return false;
}
- else {
- BLI_smallhash_insert(sh, key, item);
- return true;
- }
+
+ BLI_smallhash_insert(sh, key, item);
+ return true;
}
#ifdef USE_REMOVE
diff --git a/source/blender/blenlib/intern/sort_utils.c b/source/blender/blenlib/intern/sort_utils.c
index 09babd3d424..e02d77de0c7 100644
--- a/source/blender/blenlib/intern/sort_utils.c
+++ b/source/blender/blenlib/intern/sort_utils.c
@@ -44,12 +44,11 @@ int BLI_sortutil_cmp_float(const void *a_, const void *b_)
if (a->sort_value > b->sort_value) {
return 1;
}
- else if (a->sort_value < b->sort_value) {
+ if (a->sort_value < b->sort_value) {
return -1;
}
- else {
- return 0;
- }
+
+ return 0;
}
int BLI_sortutil_cmp_float_reverse(const void *a_, const void *b_)
@@ -59,12 +58,11 @@ int BLI_sortutil_cmp_float_reverse(const void *a_, const void *b_)
if (a->sort_value < b->sort_value) {
return 1;
}
- else if (a->sort_value > b->sort_value) {
+ if (a->sort_value > b->sort_value) {
return -1;
}
- else {
- return 0;
- }
+
+ return 0;
}
int BLI_sortutil_cmp_int(const void *a_, const void *b_)
@@ -74,12 +72,11 @@ int BLI_sortutil_cmp_int(const void *a_, const void *b_)
if (a->sort_value > b->sort_value) {
return 1;
}
- else if (a->sort_value < b->sort_value) {
+ if (a->sort_value < b->sort_value) {
return -1;
}
- else {
- return 0;
- }
+
+ return 0;
}
int BLI_sortutil_cmp_int_reverse(const void *a_, const void *b_)
@@ -89,12 +86,11 @@ int BLI_sortutil_cmp_int_reverse(const void *a_, const void *b_)
if (a->sort_value < b->sort_value) {
return 1;
}
- else if (a->sort_value > b->sort_value) {
+ if (a->sort_value > b->sort_value) {
return -1;
}
- else {
- return 0;
- }
+
+ return 0;
}
int BLI_sortutil_cmp_ptr(const void *a_, const void *b_)
@@ -104,12 +100,11 @@ int BLI_sortutil_cmp_ptr(const void *a_, const void *b_)
if (a->sort_value > b->sort_value) {
return 1;
}
- else if (a->sort_value < b->sort_value) {
+ if (a->sort_value < b->sort_value) {
return -1;
}
- else {
- return 0;
- }
+
+ return 0;
}
int BLI_sortutil_cmp_ptr_reverse(const void *a_, const void *b_)
@@ -119,10 +114,9 @@ int BLI_sortutil_cmp_ptr_reverse(const void *a_, const void *b_)
if (a->sort_value < b->sort_value) {
return 1;
}
- else if (a->sort_value > b->sort_value) {
+ if (a->sort_value > b->sort_value) {
return -1;
}
- else {
- return 0;
- }
+
+ return 0;
}
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index d3191148c90..fbd9e562b6a 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -96,9 +96,7 @@ char *BLI_current_working_dir(char *dir, const size_t maxncpy)
memcpy(dir, pwd, srclen + 1);
return dir;
}
- else {
- return NULL;
- }
+ return NULL;
}
return getcwd(dir, maxncpy);
#endif
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c
index abdae06acd5..8b4720ca1e1 100644
--- a/source/blender/blenlib/intern/string.c
+++ b/source/blender/blenlib/intern/string.c
@@ -394,9 +394,7 @@ char *BLI_str_quoted_substrN(const char *__restrict str, const char *__restrict
if (LIKELY(*(endMatch - 1) != '\\')) {
break;
}
- else {
- endMatch++;
- }
+ endMatch++;
}
if (endMatch) {
@@ -470,11 +468,9 @@ char *BLI_str_replaceN(const char *__restrict str,
return str_new;
}
- else {
- /* Just create a new copy of the entire string - we avoid going through the assembly buffer
- * for what should be a bit more efficiency. */
- return BLI_strdup(str);
- }
+ /* Just create a new copy of the entire string - we avoid going through the assembly buffer
+ * for what should be a bit more efficiency. */
+ return BLI_strdup(str);
}
/**
@@ -574,10 +570,10 @@ int BLI_strcasecmp(const char *s1, const char *s2)
if (c1 < c2) {
return -1;
}
- else if (c1 > c2) {
+ if (c1 > c2) {
return 1;
}
- else if (c1 == 0) {
+ if (c1 == 0) {
break;
}
}
@@ -597,10 +593,10 @@ int BLI_strncasecmp(const char *s1, const char *s2, size_t len)
if (c1 < c2) {
return -1;
}
- else if (c1 > c2) {
+ if (c1 > c2) {
return 1;
}
- else if (c1 == 0) {
+ if (c1 == 0) {
break;
}
}
@@ -627,15 +623,13 @@ static int left_number_strcmp(const char *s1, const char *s2, int *tiebreaker)
if (isdigit(*(p1 + numdigit)) && isdigit(*(p2 + numdigit))) {
continue;
}
- else if (isdigit(*(p1 + numdigit))) {
+ if (isdigit(*(p1 + numdigit))) {
return 1; /* s2 is bigger */
}
- else if (isdigit(*(p2 + numdigit))) {
+ if (isdigit(*(p2 + numdigit))) {
return -1; /* s1 is bigger */
}
- else {
- break;
- }
+ break;
}
/* same number of digits, compare size of number */
@@ -759,14 +753,14 @@ int BLI_strcmp_ignore_pad(const char *str1, const char *str2, const char pad)
if (str1_len == str2_len) {
return strncmp(str1, str2, str2_len);
}
- else if (str1_len > str2_len) {
+ if (str1_len > str2_len) {
int ret = strncmp(str1, str2, str2_len);
if (ret == 0) {
ret = 1;
}
return ret;
}
- else {
+ {
int ret = strncmp(str1, str2, str1_len);
if (ret == 0) {
ret = -1;
diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c
index e9fdce83710..0a723a623f0 100644
--- a/source/blender/blenlib/intern/string_utf8.c
+++ b/source/blender/blenlib/intern/string_utf8.c
@@ -215,11 +215,9 @@ int BLI_utf8_invalid_strip(char *str, size_t length)
tot++;
break;
}
- else {
- /* strip, keep looking */
- memmove(str, str + 1, length + 1); /* +1 for NULL char! */
- tot++;
- }
+ /* strip, keep looking */
+ memmove(str, str + 1, length + 1); /* +1 for NULL char! */
+ tot++;
}
return tot;
diff --git a/source/blender/blenlib/intern/string_utils.c b/source/blender/blenlib/intern/string_utils.c
index fb9530b5cb5..dbeb75570fb 100644
--- a/source/blender/blenlib/intern/string_utils.c
+++ b/source/blender/blenlib/intern/string_utils.c
@@ -72,7 +72,7 @@ size_t BLI_split_name_num(char *left, int *nr, const char *name, const char deli
}
return a;
}
- else if (isdigit(name[a]) == 0) {
+ if (isdigit(name[a]) == 0) {
/* non-numeric suffix - give up */
break;
}
diff --git a/source/blender/blenlib/intern/threads.cc b/source/blender/blenlib/intern/threads.cc
index a8333d0c696..002b78bec39 100644
--- a/source/blender/blenlib/intern/threads.cc
+++ b/source/blender/blenlib/intern/threads.cc
@@ -309,7 +309,7 @@ int BLI_system_thread_count(void)
if (num_threads_override != 0) {
return num_threads_override;
}
- else if (LIKELY(t != -1)) {
+ if (LIKELY(t != -1)) {
return t;
}
@@ -751,7 +751,7 @@ void *BLI_thread_queue_pop_timeout(ThreadQueue *queue, int ms)
if (pthread_cond_timedwait(&queue->push_cond, &queue->mutex, &timeout) == ETIMEDOUT) {
break;
}
- else if (PIL_check_seconds_timer() - t >= ms * 0.001) {
+ if (PIL_check_seconds_timer() - t >= ms * 0.001) {
break;
}
}