[Bf-blender-cvs] [50513e69645] master: Cleanup: Better const correctness and inlined key construction in depsgraph

Sergey Sharybin noreply at git.blender.org
Thu Aug 4 16:20:06 CEST 2022


Commit: 50513e6964554b059abc8351eb6b5a34b8ec60a8
Author: Sergey Sharybin
Date:   Thu Aug 4 12:24:44 2022 +0200
Branches: master
https://developer.blender.org/rB50513e6964554b059abc8351eb6b5a34b8ec60a8

Cleanup: Better const correctness and inlined key construction in depsgraph

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

M	source/blender/depsgraph/intern/builder/deg_builder_relations.h
M	source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc

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

diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
index 9d0d0135d22..db237303027 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
@@ -91,42 +91,107 @@ struct TimeSourceKey {
 };
 
 struct ComponentKey {
-  ComponentKey();
-  ComponentKey(ID *id, NodeType type, const char *name = "");
+  ComponentKey() = default;
+
+  inline ComponentKey(const ID *id, NodeType type, const char *name = "")
+      : id(id), type(type), name(name)
+  {
+  }
 
   string identifier() const;
 
-  ID *id;
-  NodeType type;
-  const char *name;
+  const ID *id = nullptr;
+  NodeType type = NodeType::UNDEFINED;
+  const char *name = "";
 };
 
 struct OperationKey {
-  OperationKey();
-  OperationKey(ID *id, NodeType component_type, const char *name, int name_tag = -1);
-  OperationKey(
-      ID *id, NodeType component_type, const char *component_name, const char *name, int name_tag);
+  OperationKey() = default;
+
+  inline OperationKey(const ID *id, NodeType component_type, const char *name, int name_tag = -1)
+      : id(id),
+        component_type(component_type),
+        component_name(""),
+        opcode(OperationCode::OPERATION),
+        name(name),
+        name_tag(name_tag)
+  {
+  }
+
+  OperationKey(const ID *id,
+               NodeType component_type,
+               const char *component_name,
+               const char *name,
+               int name_tag)
+      : id(id),
+        component_type(component_type),
+        component_name(component_name),
+        opcode(OperationCode::OPERATION),
+        name(name),
+        name_tag(name_tag)
+  {
+  }
+
+  OperationKey(const ID *id, NodeType component_type, OperationCode opcode)
+      : id(id),
+        component_type(component_type),
+        component_name(""),
+        opcode(opcode),
+        name(""),
+        name_tag(-1)
+  {
+  }
 
-  OperationKey(ID *id, NodeType component_type, OperationCode opcode);
-  OperationKey(ID *id, NodeType component_type, const char *component_name, OperationCode opcode);
+  OperationKey(const ID *id,
+               NodeType component_type,
+               const char *component_name,
+               OperationCode opcode)
+      : id(id),
+        component_type(component_type),
+        component_name(component_name),
+        opcode(opcode),
+        name(""),
+        name_tag(-1)
+  {
+  }
+
+  OperationKey(const ID *id,
+               NodeType component_type,
+               OperationCode opcode,
+               const char *name,
+               int name_tag = -1)
+      : id(id),
+        component_type(component_type),
+        component_name(""),
+        opcode(opcode),
+        name(name),
+        name_tag(name_tag)
+  {
+  }
 
-  OperationKey(
-      ID *id, NodeType component_type, OperationCode opcode, const char *name, int name_tag = -1);
-  OperationKey(ID *id,
+  OperationKey(const ID *id,
                NodeType component_type,
                const char *component_name,
                OperationCode opcode,
                const char *name,
-               int name_tag = -1);
+               int name_tag = -1)
+      : id(id),
+        component_type(component_type),
+        component_name(component_name),
+        opcode(opcode),
+        name(name),
+        name_tag(name_tag)
+  {
+  }
 
   string identifier() const;
 
-  ID *id;
-  NodeType component_type;
-  const char *component_name;
-  OperationCode opcode;
-  const char *name;
-  int name_tag;
+  const ID *id = nullptr;
+  NodeType component_type = NodeType::UNDEFINED;
+  const char *component_name = "";
+  OperationCode opcode = OperationCode::OPERATION;
+  const char *name = "";
+  int name_tag = -1;
 };
 
 struct RNAPathKey {
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc
index 13e4b615641..8506a97c408 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc
@@ -22,15 +22,6 @@ string TimeSourceKey::identifier() const
 ////////////////////////////////////////////////////////////////////////////////
 // Component.
 
-ComponentKey::ComponentKey() : id(nullptr), type(NodeType::UNDEFINED), name("")
-{
-}
-
-ComponentKey::ComponentKey(ID *id, NodeType type, const char *name)
-    : id(id), type(type), name(name)
-{
-}
-
 string ComponentKey::identifier() const
 {
   const char *idname = (id) ? id->name : "<None>";
@@ -47,86 +38,6 @@ string ComponentKey::identifier() const
 ////////////////////////////////////////////////////////////////////////////////
 // Operation.
 
-OperationKey::OperationKey()
-    : id(nullptr),
-      component_type(NodeType::UNDEFINED),
-      component_name(""),
-      opcode(OperationCode::OPERATION),
-      name(""),
-      name_tag(-1)
-{
-}
-
-OperationKey::OperationKey(ID *id, NodeType component_type, const char *name, int name_tag)
-    : id(id),
-      component_type(component_type),
-      component_name(""),
-      opcode(OperationCode::OPERATION),
-      name(name),
-      name_tag(name_tag)
-{
-}
-
-OperationKey::OperationKey(
-    ID *id, NodeType component_type, const char *component_name, const char *name, int name_tag)
-    : id(id),
-      component_type(component_type),
-      component_name(component_name),
-      opcode(OperationCode::OPERATION),
-      name(name),
-      name_tag(name_tag)
-{
-}
-
-OperationKey::OperationKey(ID *id, NodeType component_type, OperationCode opcode)
-    : id(id),
-      component_type(component_type),
-      component_name(""),
-      opcode(opcode),
-      name(""),
-      name_tag(-1)
-{
-}
-
-OperationKey::OperationKey(ID *id,
-                           NodeType component_type,
-                           const char *component_name,
-                           OperationCode opcode)
-    : id(id),
-      component_type(component_type),
-      component_name(component_name),
-      opcode(opcode),
-      name(""),
-      name_tag(-1)
-{
-}
-
-OperationKey::OperationKey(
-    ID *id, NodeType component_type, OperationCode opcode, const char *name, int name_tag)
-    : id(id),
-      component_type(component_type),
-      component_name(""),
-      opcode(opcode),
-      name(name),
-      name_tag(name_tag)
-{
-}
-
-OperationKey::OperationKey(ID *id,
-                           NodeType component_type,
-                           const char *component_name,
-                           OperationCode opcode,
-                           const char *name,
-                           int name_tag)
-    : id(id),
-      component_type(component_type),
-      component_name(component_name),
-      opcode(opcode),
-      name(name),
-      name_tag(name_tag)
-{
-}
-
 string OperationKey::identifier() const
 {
   string result = string("OperationKey(");



More information about the Bf-blender-cvs mailing list