[Bf-blender-cvs] [b4563ab2dfe] master: Cleanup: avoid generating some functions in all translation units

Jacques Lucke noreply at git.blender.org
Fri Feb 4 17:21:52 CET 2022


Commit: b4563ab2dfe1e553bfe48d50592823ff13a49692
Author: Jacques Lucke
Date:   Fri Feb 4 17:18:41 2022 +0100
Branches: master
https://developer.blender.org/rBb4563ab2dfe1e553bfe48d50592823ff13a49692

Cleanup: avoid generating some functions in all translation units

Every translation unit that included the modified headers generated
some extra code, even though it was not used. This adds unnecessary
compile time overhead and is annoying when investigating the
generated assembly.

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

M	source/blender/blenlib/BLI_enumerable_thread_specific.hh
M	source/blender/functions/FN_field.hh
M	source/blender/functions/intern/field.cc

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

diff --git a/source/blender/blenlib/BLI_enumerable_thread_specific.hh b/source/blender/blenlib/BLI_enumerable_thread_specific.hh
index b5981028893..ce7df1ff4b9 100644
--- a/source/blender/blenlib/BLI_enumerable_thread_specific.hh
+++ b/source/blender/blenlib/BLI_enumerable_thread_specific.hh
@@ -28,10 +28,12 @@
 
 namespace blender::threading {
 
+#ifndef WITH_TBB
 namespace enumerable_thread_specific_utils {
 inline std::atomic<int> next_id = 0;
 inline thread_local int thread_id = next_id.fetch_add(1, std::memory_order_relaxed);
 }  // namespace enumerable_thread_specific_utils
+#endif
 
 /**
  * This is mainly a wrapper for `tbb::enumerable_thread_specific`. The wrapper is needed because we
diff --git a/source/blender/functions/FN_field.hh b/source/blender/functions/FN_field.hh
index e869927c33b..e42feac1644 100644
--- a/source/blender/functions/FN_field.hh
+++ b/source/blender/functions/FN_field.hh
@@ -87,8 +87,7 @@ class FieldNode {
 
  public:
   FieldNode(FieldNodeType node_type);
-
-  virtual ~FieldNode() = default;
+  virtual ~FieldNode();
 
   virtual const CPPType &output_cpp_type(int output_index) const = 0;
 
@@ -230,6 +229,7 @@ class FieldOperation : public FieldNode {
  public:
   FieldOperation(std::shared_ptr<const MultiFunction> function, Vector<GField> inputs = {});
   FieldOperation(const MultiFunction &function, Vector<GField> inputs = {});
+  ~FieldOperation();
 
   Span<GField> inputs() const;
   const MultiFunction &multi_function() const;
@@ -259,6 +259,7 @@ class FieldInput : public FieldNode {
 
  public:
   FieldInput(const CPPType &type, std::string debug_name = "");
+  ~FieldInput();
 
   /**
    * Get the value of this specific input based on the given context. The returned virtual array,
diff --git a/source/blender/functions/intern/field.cc b/source/blender/functions/intern/field.cc
index d6b83c42294..fe3041b8602 100644
--- a/source/blender/functions/intern/field.cc
+++ b/source/blender/functions/intern/field.cc
@@ -570,6 +570,13 @@ bool IndexFieldInput::is_equal_to(const fn::FieldNode &other) const
   return dynamic_cast<const IndexFieldInput *>(&other) != nullptr;
 }
 
+/* --------------------------------------------------------------------
+ * FieldNode.
+ */
+
+/* Avoid generating the destructor in every translation unit. */
+FieldNode::~FieldNode() = default;
+
 /* --------------------------------------------------------------------
  * FieldOperation.
  */
@@ -581,6 +588,9 @@ FieldOperation::FieldOperation(std::shared_ptr<const MultiFunction> function,
   owned_function_ = std::move(function);
 }
 
+/* Avoid generating the destructor in every translation unit. */
+FieldOperation::~FieldOperation() = default;
+
 /**
  * Returns the field inputs used by all the provided fields.
  * This tries to reuse an existing #FieldInputs whenever possible to avoid copying it.
@@ -655,6 +665,9 @@ FieldInput::FieldInput(const CPPType &type, std::string debug_name)
   field_inputs_ = std::move(field_inputs);
 }
 
+/* Avoid generating the destructor in every translation unit. */
+FieldInput::~FieldInput() = default;
+
 /* --------------------------------------------------------------------
  * FieldConstant.
  */



More information about the Bf-blender-cvs mailing list