[Bf-blender-cvs] [468be50313f] functions: remove unnecessary small object optimization for monotonic allocator

Jacques Lucke noreply at git.blender.org
Wed Aug 7 11:07:07 CEST 2019


Commit: 468be50313fd7a7aeae4cf71e17cea964b1a8ed6
Author: Jacques Lucke
Date:   Wed Aug 7 09:33:37 2019 +0200
Branches: functions
https://developer.blender.org/rB468be50313fd7a7aeae4cf71e17cea964b1a8ed6

remove unnecessary small object optimization for monotonic allocator

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

M	source/blender/blenkernel/BKE_node_tree.hpp
M	source/blender/blenlib/BLI_monotonic_allocator.hpp
M	source/blender/functions/core/data_graph.cpp
M	source/blender/functions/core/data_graph.hpp
M	source/blender/functions/core/data_graph_builder.cpp
M	source/blender/functions/core/data_graph_builder.hpp

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

diff --git a/source/blender/blenkernel/BKE_node_tree.hpp b/source/blender/blenkernel/BKE_node_tree.hpp
index fa69169fb7b..031816da400 100644
--- a/source/blender/blenkernel/BKE_node_tree.hpp
+++ b/source/blender/blenkernel/BKE_node_tree.hpp
@@ -39,7 +39,7 @@ class VirtualNodeTree {
   Vector<VirtualSocket *> m_inputs_with_links;
   MultiMap<std::string, VirtualNode *> m_nodes_by_idname;
   uint m_socket_counter = 0;
-  MonotonicAllocator<> m_allocator;
+  MonotonicAllocator m_allocator;
 
  public:
   void add_all_of_tree(bNodeTree *btree);
diff --git a/source/blender/blenlib/BLI_monotonic_allocator.hpp b/source/blender/blenlib/BLI_monotonic_allocator.hpp
index abf6d3efa69..ceefa1a2b7e 100644
--- a/source/blender/blenlib/BLI_monotonic_allocator.hpp
+++ b/source/blender/blenlib/BLI_monotonic_allocator.hpp
@@ -4,16 +4,13 @@
  * A monotonic allocator is the simplest form of an allocator. It never reuses any memory, and
  * therefore does not need a deallocation method. It simply hands out consecutive buffers of
  * memory. When the current buffer is full, it reallocates a new larger buffer and continues.
- *
- * It optionally supports small object optimization. So e.g. when in total less then 20 bytes are
- * allocated, no actual allocation will be performed.
  */
 
 #include "BLI_vector.hpp"
 
 namespace BLI {
 
-template<uint N = 0> class MonotonicAllocator {
+class MonotonicAllocator {
  private:
   Vector<void *> m_pointers;
 
@@ -21,13 +18,9 @@ template<uint N = 0> class MonotonicAllocator {
   uint m_remaining_capacity;
   uint m_next_min_alloc_size;
 
-  char m_small_buffer[N];
-
  public:
   MonotonicAllocator()
-      : m_current_buffer((void *)m_small_buffer),
-        m_remaining_capacity(N),
-        m_next_min_alloc_size(N * 2)
+      : m_current_buffer(nullptr), m_remaining_capacity(0), m_next_min_alloc_size(16)
   {
   }
 
diff --git a/source/blender/functions/core/data_graph.cpp b/source/blender/functions/core/data_graph.cpp
index c1e04f28d1a..44d541ca33c 100644
--- a/source/blender/functions/core/data_graph.cpp
+++ b/source/blender/functions/core/data_graph.cpp
@@ -6,7 +6,7 @@ DataGraph::DataGraph(Vector<Node> nodes,
                      Vector<InputSocket> inputs,
                      Vector<OutputSocket> outputs,
                      Vector<uint> targets,
-                     std::unique_ptr<MonotonicAllocator<>> source_info_allocator)
+                     std::unique_ptr<MonotonicAllocator> source_info_allocator)
     : m_nodes(std::move(nodes)),
       m_inputs(std::move(inputs)),
       m_outputs(std::move(outputs)),
diff --git a/source/blender/functions/core/data_graph.hpp b/source/blender/functions/core/data_graph.hpp
index e28d4cafab5..f7b15298d23 100644
--- a/source/blender/functions/core/data_graph.hpp
+++ b/source/blender/functions/core/data_graph.hpp
@@ -201,14 +201,14 @@ class DataGraph : public RefCounter {
   Vector<InputSocket> m_inputs;
   Vector<OutputSocket> m_outputs;
   Vector<uint> m_targets;
-  std::unique_ptr<MonotonicAllocator<>> m_source_info_allocator;
+  std::unique_ptr<MonotonicAllocator> m_source_info_allocator;
 
  public:
   DataGraph(Vector<Node> nodes,
             Vector<InputSocket> inputs,
             Vector<OutputSocket> outputs,
             Vector<uint> targets,
-            std::unique_ptr<MonotonicAllocator<>> source_info_allocator);
+            std::unique_ptr<MonotonicAllocator> source_info_allocator);
 
   DataGraph(DataGraph &other) = delete;
   ~DataGraph();
diff --git a/source/blender/functions/core/data_graph_builder.cpp b/source/blender/functions/core/data_graph_builder.cpp
index cfffcd57a54..f9de86b0f72 100644
--- a/source/blender/functions/core/data_graph_builder.cpp
+++ b/source/blender/functions/core/data_graph_builder.cpp
@@ -2,7 +2,7 @@
 
 namespace FN {
 
-DataGraphBuilder::DataGraphBuilder() : m_source_info_allocator(new MonotonicAllocator<>())
+DataGraphBuilder::DataGraphBuilder() : m_source_info_allocator(new MonotonicAllocator())
 {
 }
 
diff --git a/source/blender/functions/core/data_graph_builder.hpp b/source/blender/functions/core/data_graph_builder.hpp
index 78a57b0f777..240e75ae090 100644
--- a/source/blender/functions/core/data_graph_builder.hpp
+++ b/source/blender/functions/core/data_graph_builder.hpp
@@ -144,9 +144,9 @@ class DataGraphBuilder {
   uint m_link_counter = 0;
   uint m_input_socket_counter = 0;
   uint m_output_socket_counter = 0;
-  std::unique_ptr<MonotonicAllocator<>> m_source_info_allocator;
-  MonotonicAllocator<> m_allocator;
-  
+  std::unique_ptr<MonotonicAllocator> m_source_info_allocator;
+  MonotonicAllocator m_allocator;
+
  public:
   DataGraphBuilder();
   DataGraphBuilder(DataGraphBuilder &other) = delete;



More information about the Bf-blender-cvs mailing list