From c04088fed1b8faea6b2928bb5e09ab367076950c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 7 Aug 2020 13:37:22 +0200 Subject: Cleanup: Clang-Tidy else-after-return fixes This addresses warnings from Clang-Tidy's `readability-else-after-return` rule. This should be the final commit of the series of commits that addresses this particular rule. No functional changes. --- source/blender/functions/intern/attributes_ref.cc | 13 ++--- .../intern/multi_function_network_evaluation.cc | 64 ++++++++++------------ .../intern/multi_function_network_optimization.cc | 5 +- 3 files changed, 37 insertions(+), 45 deletions(-) (limited to 'source/blender/functions') diff --git a/source/blender/functions/intern/attributes_ref.cc b/source/blender/functions/intern/attributes_ref.cc index 8f7f41be079..9f1e7fa65e5 100644 --- a/source/blender/functions/intern/attributes_ref.cc +++ b/source/blender/functions/intern/attributes_ref.cc @@ -42,14 +42,13 @@ bool AttributesInfoBuilder::add(StringRef name, const CPPType &type, const void defaults_.append(dst); return true; } - else { - const CPPType &stored_type = *types_[names_.index_of_as(name)]; - if (stored_type != type) { - std::cout << "Warning: Tried to add an attribute twice with different types (" << name - << ": " << stored_type.name() << ", " << type.name() << ").\n"; - } - return false; + + const CPPType &stored_type = *types_[names_.index_of_as(name)]; + if (stored_type != type) { + std::cout << "Warning: Tried to add an attribute twice with different types (" << name << ": " + << stored_type.name() << ", " << type.name() << ").\n"; } + return false; } AttributesInfo::AttributesInfo(const AttributesInfoBuilder &builder) diff --git a/source/blender/functions/intern/multi_function_network_evaluation.cc b/source/blender/functions/intern/multi_function_network_evaluation.cc index 25e983d2eeb..480a048b510 100644 --- a/source/blender/functions/intern/multi_function_network_evaluation.cc +++ b/source/blender/functions/intern/multi_function_network_evaluation.cc @@ -519,7 +519,7 @@ MFNetworkEvaluationStorage::~MFNetworkEvaluationStorage() if (any_value == nullptr) { continue; } - else if (any_value->type == ValueType::OwnSingle) { + if (any_value->type == ValueType::OwnSingle) { OwnSingleValue *value = (OwnSingleValue *)any_value; GMutableSpan span = value->span; const CPPType &type = span.type(); @@ -710,10 +710,9 @@ GMutableSpan MFNetworkEvaluationStorage::get_single_output__full(const MFOutputS return span; } - else { - BLI_assert(any_value->type == ValueType::OutputSingle); - return ((OutputSingleValue *)any_value)->span; - } + + BLI_assert(any_value->type == ValueType::OutputSingle); + return ((OutputSingleValue *)any_value)->span; } GMutableSpan MFNetworkEvaluationStorage::get_single_output__single(const MFOutputSocket &socket) @@ -729,12 +728,11 @@ GMutableSpan MFNetworkEvaluationStorage::get_single_output__single(const MFOutpu return value->span; } - else { - BLI_assert(any_value->type == ValueType::OutputSingle); - GMutableSpan span = ((OutputSingleValue *)any_value)->span; - BLI_assert(span.size() == 1); - return span; - } + + BLI_assert(any_value->type == ValueType::OutputSingle); + GMutableSpan span = ((OutputSingleValue *)any_value)->span; + BLI_assert(span.size() == 1); + return span; } GVectorArray &MFNetworkEvaluationStorage::get_vector_output__full(const MFOutputSocket &socket) @@ -749,10 +747,9 @@ GVectorArray &MFNetworkEvaluationStorage::get_vector_output__full(const MFOutput return *value->vector_array; } - else { - BLI_assert(any_value->type == ValueType::OutputVector); - return *((OutputVectorValue *)any_value)->vector_array; - } + + BLI_assert(any_value->type == ValueType::OutputVector); + return *((OutputVectorValue *)any_value)->vector_array; } GVectorArray &MFNetworkEvaluationStorage::get_vector_output__single(const MFOutputSocket &socket) @@ -767,12 +764,11 @@ GVectorArray &MFNetworkEvaluationStorage::get_vector_output__single(const MFOutp return *value->vector_array; } - else { - BLI_assert(any_value->type == ValueType::OutputVector); - GVectorArray &vector_array = *((OutputVectorValue *)any_value)->vector_array; - BLI_assert(vector_array.size() == 1); - return vector_array; - } + + BLI_assert(any_value->type == ValueType::OutputVector); + GVectorArray &vector_array = *((OutputVectorValue *)any_value)->vector_array; + BLI_assert(vector_array.size() == 1); + return vector_array; } GMutableSpan MFNetworkEvaluationStorage::get_mutable_single__full(const MFInputSocket &input, @@ -955,15 +951,14 @@ GVSpan MFNetworkEvaluationStorage::get_single_input__full(const MFInputSocket &s if (value->is_single_allocated) { return GVSpan::FromSingle(value->span.type(), value->span.data(), min_array_size_); } - else { - return value->span; - } + + return value->span; } - else if (any_value->type == ValueType::InputSingle) { + if (any_value->type == ValueType::InputSingle) { InputSingleValue *value = (InputSingleValue *)any_value; return value->virtual_span; } - else if (any_value->type == ValueType::OutputSingle) { + if (any_value->type == ValueType::OutputSingle) { OutputSingleValue *value = (OutputSingleValue *)any_value; BLI_assert(value->is_computed); return value->span; @@ -984,12 +979,12 @@ GVSpan MFNetworkEvaluationStorage::get_single_input__single(const MFInputSocket BLI_assert(value->span.size() == 1); return value->span; } - else if (any_value->type == ValueType::InputSingle) { + if (any_value->type == ValueType::InputSingle) { InputSingleValue *value = (InputSingleValue *)any_value; BLI_assert(value->virtual_span.is_single_element()); return value->virtual_span; } - else if (any_value->type == ValueType::OutputSingle) { + if (any_value->type == ValueType::OutputSingle) { OutputSingleValue *value = (OutputSingleValue *)any_value; BLI_assert(value->is_computed); BLI_assert(value->span.size() == 1); @@ -1012,15 +1007,14 @@ GVArraySpan MFNetworkEvaluationStorage::get_vector_input__full(const MFInputSock GSpan span = (*value->vector_array)[0]; return GVArraySpan(span, min_array_size_); } - else { - return *value->vector_array; - } + + return *value->vector_array; } - else if (any_value->type == ValueType::InputVector) { + if (any_value->type == ValueType::InputVector) { InputVectorValue *value = (InputVectorValue *)any_value; return value->virtual_array_span; } - else if (any_value->type == ValueType::OutputVector) { + if (any_value->type == ValueType::OutputVector) { OutputVectorValue *value = (OutputVectorValue *)any_value; return *value->vector_array; } @@ -1040,12 +1034,12 @@ GVArraySpan MFNetworkEvaluationStorage::get_vector_input__single(const MFInputSo BLI_assert(value->vector_array->size() == 1); return *value->vector_array; } - else if (any_value->type == ValueType::InputVector) { + if (any_value->type == ValueType::InputVector) { InputVectorValue *value = (InputVectorValue *)any_value; BLI_assert(value->virtual_array_span.is_single_array()); return value->virtual_array_span; } - else if (any_value->type == ValueType::OutputVector) { + if (any_value->type == ValueType::OutputVector) { OutputVectorValue *value = (OutputVectorValue *)any_value; BLI_assert(value->vector_array->size() == 1); return *value->vector_array; diff --git a/source/blender/functions/intern/multi_function_network_optimization.cc b/source/blender/functions/intern/multi_function_network_optimization.cc index af1e77aa355..e53b9a2c648 100644 --- a/source/blender/functions/intern/multi_function_network_optimization.cc +++ b/source/blender/functions/intern/multi_function_network_optimization.cc @@ -45,9 +45,8 @@ static bool set_tag_and_check_if_modified(bool &tag, bool new_value) tag = new_value; return true; } - else { - return false; - } + + return false; } static Array mask_nodes_to_the_left(MFNetwork &network, Span nodes) -- cgit v1.2.3