[Bf-blender-cvs] [d58b2c258b4] soc-2020-io-performance: Cleanup: Clang-tidy else-after-return
Ankit Meel
noreply at git.blender.org
Sat Nov 7 14:17:38 CET 2020
Commit: d58b2c258b4b2ac866d0a1a683097025beab8b73
Author: Ankit Meel
Date: Sat Nov 7 18:24:56 2020 +0530
Branches: soc-2020-io-performance
https://developer.blender.org/rBd58b2c258b4b2ac866d0a1a683097025beab8b73
Cleanup: Clang-tidy else-after-return
===================================================================
M intern/sky/source/sky_nishita.cpp
M source/blender/makesrna/intern/makesrna.c
M source/blender/makesrna/intern/rna_access.c
M source/blender/makesrna/intern/rna_access_compare_override.c
M source/blender/makesrna/intern/rna_define.c
M source/creator/creator.c
M source/creator/creator_args.c
===================================================================
diff --git a/intern/sky/source/sky_nishita.cpp b/intern/sky/source/sky_nishita.cpp
index f36bfcc3d7b..68fc2085448 100644
--- a/intern/sky/source/sky_nishita.cpp
+++ b/intern/sky/source/sky_nishita.cpp
@@ -112,10 +112,12 @@ static float density_mie(float height)
static float density_ozone(float height)
{
float den = 0.0f;
- if (height >= 10000.0f && height < 25000.0f)
+ if (height >= 10000.0f && height < 25000.0f) {
den = 1.0f / 15000.0f * height - 2.0f / 3.0f;
- else if (height >= 25000 && height < 40000)
+ }
+ else if (height >= 25000 && height < 40000) {
den = -(1.0f / 15000.0f * height - 8.0f / 3.0f);
+ }
return den;
}
@@ -133,15 +135,16 @@ static float phase_mie(float mu)
/* Intersection helpers */
static bool surface_intersection(float3 pos, float3 dir)
{
- if (dir.z >= 0)
+ if (dir.z >= 0) {
return false;
+ }
float b = -2.0f * dot(dir, -pos);
float c = len_squared(pos) - sqr(earth_radius);
float t = b * b - 4.0f * c;
- if (t >= 0.0f)
+ if (t >= 0.0f) {
return true;
- else
- return false;
+ }
+ return false;
}
static float3 atmosphere_intersection(float3 pos, float3 dir)
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 5aa684539af..8b861d20e4e 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -256,10 +256,10 @@ static const char *rna_safe_id(const char *id)
if (STREQ(id, "operator")) {
return "operator_value";
}
- else if (STREQ(id, "new")) {
+ if (STREQ(id, "new")) {
return "create";
}
- else if (STREQ(id, "co_return")) {
+ if (STREQ(id, "co_return")) {
/* MSVC2015, C++ uses for coroutines */
return "coord_return";
}
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index a631fe4fc26..361168bcf3f 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -425,9 +425,7 @@ static int rna_ensure_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
if (idprop->type == IDP_ARRAY) {
return idprop->len;
}
- else {
- return 0;
- }
+ return 0;
}
static bool rna_ensure_property_array_check(PropertyRNA *prop)
@@ -1268,7 +1266,7 @@ char RNA_property_array_item_char(PropertyRNA *prop, int index)
PROP_COORDS)) {
return vectoritem[index];
}
- else if ((index < 4) && ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA)) {
+ if ((index < 4) && ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA)) {
return coloritem[index];
}
@@ -1533,9 +1531,7 @@ int RNA_property_float_clamp(PointerRNA *ptr, PropertyRNA *prop, float *value)
*value = max;
return 1;
}
- else {
- return 0;
- }
+ return 0;
}
int RNA_property_int_clamp(PointerRNA *ptr, PropertyRNA *prop, int *value)
@@ -1552,9 +1548,7 @@ int RNA_property_int_clamp(PointerRNA *ptr, PropertyRNA *prop, int *value)
*value = max;
return 1;
}
- else {
- return 0;
- }
+ return 0;
}
/* this is the max length including \0 terminator.
@@ -2614,7 +2608,7 @@ int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
if (iprop->get) {
return iprop->get(ptr);
}
- else if (iprop->get_ex) {
+ if (iprop->get_ex) {
return iprop->get_ex(ptr, prop);
}
else {
@@ -2950,7 +2944,7 @@ float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
}
return (float)IDP_Double(idprop);
}
- else if (fprop->get) {
+ if (fprop->get) {
return fprop->get(ptr);
}
else if (fprop->get_ex) {
@@ -3389,7 +3383,7 @@ int RNA_property_string_length(PointerRNA *ptr, PropertyRNA *prop)
#endif
return idprop->len - 1;
}
- else if (sprop->length) {
+ if (sprop->length) {
return sprop->length(ptr);
}
else if (sprop->length_ex) {
@@ -3555,7 +3549,7 @@ int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
if (eprop->get) {
return eprop->get(ptr);
}
- else if (eprop->get_ex) {
+ if (eprop->get_ex) {
return eprop->get_ex(ptr, prop);
}
else {
@@ -3671,7 +3665,7 @@ PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
}
return rna_pointer_inherit_refine(ptr, pprop->type, idprop);
}
- else if (pprop->get) {
+ if (pprop->get) {
return pprop->get(ptr);
}
else if (prop->flag & PROP_IDPROPERTY) {
@@ -3924,18 +3918,16 @@ int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop)
if (cprop->length) {
return cprop->length(ptr);
}
- else {
- CollectionPropertyIterator iter;
- int length = 0;
-
- RNA_property_collection_begin(ptr, prop, &iter);
- for (; iter.valid; RNA_property_collection_next(&iter)) {
- length++;
- }
- RNA_property_collection_end(&iter);
+ CollectionPropertyIterator iter;
+ int length = 0;
- return length;
+ RNA_property_collection_begin(ptr, prop, &iter);
+ for (; iter.valid; RNA_property_collection_next(&iter)) {
+ length++;
}
+ RNA_property_collection_end(&iter);
+
+ return length;
}
/* This helper checks whether given collection property itself is editable (we only currently
@@ -5775,21 +5767,19 @@ static char *rna_idp_path(PointerRNA *ptr,
path = rna_idp_path_create(&link);
break;
}
- else {
- int j;
- link.name = iter->name;
- for (j = 0; j < iter->len; j++, array++) {
- PointerRNA child_ptr;
- if (RNA_property_collection_lookup_int(ptr, prop, j, &child_ptr)) {
- link.index = j;
- if ((path = rna_idp_path(&child_ptr, array, needle, &link))) {
- break;
- }
+ int j;
+ link.name = iter->name;
+ for (j = 0; j < iter->len; j++, array++) {
+ PointerRNA child_ptr;
+ if (RNA_property_collection_lookup_int(ptr, prop, j, &child_ptr)) {
+ link.index = j;
+ if ((path = rna_idp_path(&child_ptr, array, needle, &link))) {
+ break;
}
}
- if (path) {
- break;
- }
+ }
+ if (path) {
+ break;
}
}
}
@@ -6788,9 +6778,7 @@ static char *rna_pointer_as_string__bldata(Main *bmain, PointerRNA *ptr)
if (RNA_struct_is_ID(ptr->type)) {
return RNA_path_full_ID_py(bmain, ptr->owner_id);
}
- else {
- return RNA_path_full_struct_py(bmain, ptr);
- }
+ return RNA_path_full_struct_py(bmain, ptr);
}
char *RNA_pointer_as_string(bContext *C,
@@ -6805,9 +6793,7 @@ char *RNA_pointer_as_string(bContext *C,
if ((prop = rna_idproperty_check(&prop_ptr, ptr)) && prop->type != IDP_ID) {
return RNA_pointer_as_string_id(C, ptr_prop);
}
- else {
- return rna_pointer_as_string__bldata(CTX_data_main(C), ptr_prop);
- }
+ return rna_pointer_as_string__bldata(CTX_data_main(C), ptr_prop);
}
/* context can be NULL */
diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c
index d367bc663f1..4bbbf5f01da 100644
--- a/source/blender/makesrna/intern/rna_access_compare_override.c
+++ b/source/blender/makesrna/intern/rna_access_compare_override.c
@@ -211,7 +211,7 @@ bool RNA_struct_equals(Main *bmain, PointerRNA *ptr_a, PointerRNA *ptr_b, eRNACo
if (ptr_a == NULL || ptr_b == NULL) {
return false;
}
- else if (ptr_a->type != ptr_b->type) {
+ if (ptr_a->type != ptr_b->type) {
return false;
}
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index b298d49fad5..b437e60ecf9 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -513,7 +513,7 @@ static int rna_find_sdna_member(SDNA *sdna,
return 1;
}
- else if (cmp == 3) {
+ if (cmp == 3) {
smember->type = "";
smember->name = dnaname;
smember->offset = *offset;
@@ -2199,15 +2199,13 @@ static PropertyDefRNA *rna_def_property_sdna(PropertyRNA *prop,
dp->dnaoffset = smember.offset;
return dp;
}
- else {
- CLOG_ERROR(&LOG,
- "\"%s.%s\" (identifier \"%s\") not found. Struct must be in DNA.",
- structname,
- propname,
- prop->identifier);
- DefRNA.error = true;
- return NULL;
- }
+ CLOG_ERROR(&LOG,
+ "\"%s.%s\" (identifier \"%s\") not found. Struct must be in DNA.",
+ structname,
+ propname,
+ prop->identifier);
+ DefRNA.error = true;
+ return NULL;
}
if (smember.arraylength > 1) {
@@ -4363,9 +4361,8 @@ int rna_parameter_size(PropertyRNA *parm)
}
return sizeof(PointerRNA *);
}
- else {
- return sizeof(void *);
- }
+ return sizeof(void *);
+
#endif
}
case PROP_COLLECTION:
diff --git a/source/creator/creator.c b/source/creator/creator.c
index 3365dad75d1..fee97e5090f 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -293,7 +293,7 @@ int main(int argc,
MEM_use_guarded_allocator();
break;
}
- else if (STREQ(argv[i], "--")) {
+ if (STREQ(argv[i], "--")) {
break;
}
}
diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c
index 077eb4e6821..58601dcb6af 100644
--- a/source/creator/creator_args.c
+++ b/source/creator/creator_args.c
@@ -119,7 +119,7 @@ static bool parse_int_relative(const char *str,
*r_err_msg = msg;
return false;
}
- else if ((errno == ERANGE) || ((value < INT_MIN || value > INT_MAX))) {
+ if ((errno == ERANGE) || ((value < INT_MIN || value > INT_MAX))) {
static const char *msg = "exceeds range";
*r_err_msg = msg;
return false;
@@ -166,9 +166,7 @@ static bool parse_int_range_relative(const char *str,
str_end_range + 2, str_end_test, pos, neg, &r_value_range[1], r_err_msg)) {
return true;
}
- else {
- return false;
- }
+ return false;
}
static bool parse_int_relative_clamp(const char *str,
@@ -184,9 +182,7 @@ static bool parse_int_relative_clamp
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list