From ea8ff59c274327dd335f668ff8a4d92c883191af Mon Sep 17 00:00:00 2001 From: Joao Matos Date: Fri, 28 Feb 2025 11:56:06 +0000 Subject: [PATCH] App: Refactor with early exit in `Document::recomputeFeature`. --- src/App/Document.cpp | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/App/Document.cpp b/src/App/Document.cpp index ecf12cc3a7..5df163ff77 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -3391,26 +3391,25 @@ int Document::_recomputeFeature(DocumentObject* Feat) return 0; } -bool Document::recomputeFeature(DocumentObject* Feat, bool recursive) +bool Document::recomputeFeature(DocumentObject* feature, bool recursive) { // delete recompute log - d->clearRecomputeLog(Feat); + d->clearRecomputeLog(feature); // verify that the feature is (active) part of the document - if (Feat->isAttachedToDocument()) { - if (recursive) { - bool hasError = false; - recompute({Feat}, true, &hasError); - return !hasError; - } - else { - _recomputeFeature(Feat); - signalRecomputedObject(*Feat); - return Feat->isValid(); - } + if (!feature->isAttachedToDocument()) { + return false; + } + + if (recursive) { + bool hasError = false; + recompute({feature}, true, &hasError); + return !hasError; } else { - return false; + _recomputeFeature(feature); + signalRecomputedObject(*feature); + return feature->isValid(); } }