[Bf-blender-cvs] [1a02c0d7ddd] master: Cleanup: Return early for null check

Hans Goudey noreply at git.blender.org
Fri Dec 10 23:42:58 CET 2021


Commit: 1a02c0d7ddd816a2b14024dad106131ab273183d
Author: Hans Goudey
Date:   Fri Dec 10 16:42:16 2021 -0600
Branches: master
https://developer.blender.org/rB1a02c0d7ddd816a2b14024dad106131ab273183d

Cleanup: Return early for null check

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

M	source/blender/blenkernel/intern/node.cc

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

diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc
index d25a474dbed..74c762439c7 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -3418,40 +3418,39 @@ void ntreeNodeFlagSet(const bNodeTree *ntree, const int flag, const bool enable)
 
 bNodeTree *ntreeLocalize(bNodeTree *ntree)
 {
-  if (ntree) {
-    /* Make full copy outside of Main database.
-     * NOTE: previews are not copied here.
-     */
-    bNodeTree *ltree = (bNodeTree *)BKE_id_copy_ex(
-        nullptr, &ntree->id, nullptr, (LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_NO_ANIMDATA));
-
-    ltree->id.tag |= LIB_TAG_LOCALIZED;
+  if (ntree == nullptr) {
+    return nullptr;
+  }
 
-    LISTBASE_FOREACH (bNode *, node, &ltree->nodes) {
-      if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && node->id) {
-        node->id = (ID *)ntreeLocalize((bNodeTree *)node->id);
-      }
-    }
+  /* Make full copy outside of Main database.
+   * NOTE: previews are not copied here. */
+  bNodeTree *ltree = (bNodeTree *)BKE_id_copy_ex(
+      nullptr, &ntree->id, nullptr, (LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_NO_ANIMDATA));
 
-    /* ensures only a single output node is enabled */
-    ntreeSetOutput(ntree);
+  ltree->id.tag |= LIB_TAG_LOCALIZED;
 
-    bNode *node_src = (bNode *)ntree->nodes.first;
-    bNode *node_local = (bNode *)ltree->nodes.first;
-    while (node_src != nullptr) {
-      node_local->original = node_src;
-      node_src = node_src->next;
-      node_local = node_local->next;
+  LISTBASE_FOREACH (bNode *, node, &ltree->nodes) {
+    if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && node->id) {
+      node->id = (ID *)ntreeLocalize((bNodeTree *)node->id);
     }
+  }
 
-    if (ntree->typeinfo->localize) {
-      ntree->typeinfo->localize(ltree, ntree);
-    }
+  /* ensures only a single output node is enabled */
+  ntreeSetOutput(ntree);
+
+  bNode *node_src = (bNode *)ntree->nodes.first;
+  bNode *node_local = (bNode *)ltree->nodes.first;
+  while (node_src != nullptr) {
+    node_local->original = node_src;
+    node_src = node_src->next;
+    node_local = node_local->next;
+  }
 
-    return ltree;
+  if (ntree->typeinfo->localize) {
+    ntree->typeinfo->localize(ltree, ntree);
   }
 
-  return nullptr;
+  return ltree;
 }
 
 void ntreeLocalSync(bNodeTree *localtree, bNodeTree *ntree)



More information about the Bf-blender-cvs mailing list