[Bf-blender-cvs] [b07660a2b9f] temp-geometry-nodes-evaluator-refactor: cleanup

Jacques Lucke noreply at git.blender.org
Wed Sep 7 13:02:58 CEST 2022


Commit: b07660a2b9feb2c1324f16a14a71aad320025d6f
Author: Jacques Lucke
Date:   Wed Sep 7 12:53:52 2022 +0200
Branches: temp-geometry-nodes-evaluator-refactor
https://developer.blender.org/rBb07660a2b9feb2c1324f16a14a71aad320025d6f

cleanup

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

D	source/blender/blenlib/BLI_context_stack_map.hh
M	source/blender/blenlib/CMakeLists.txt
D	source/blender/blenlib/tests/BLI_context_stack_test.cc
M	source/blender/nodes/NOD_geometry_nodes_log.hh

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

diff --git a/source/blender/blenlib/BLI_context_stack_map.hh b/source/blender/blenlib/BLI_context_stack_map.hh
deleted file mode 100644
index 9c2e54d2916..00000000000
--- a/source/blender/blenlib/BLI_context_stack_map.hh
+++ /dev/null
@@ -1,54 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-
-#pragma once
-
-/** \file
- * \ingroup bli
- */
-
-#include "BLI_context_stack.hh"
-#include "BLI_linear_allocator.hh"
-#include "BLI_map.hh"
-
-namespace blender {
-
-template<typename T> class ContextStackMap {
- private:
-  LinearAllocator<> allocator_;
-  Map<ContextStackHash, destruct_ptr<T>> map_;
-
- public:
-  T &lookup_or_add(const ContextStack &context_stack)
-  {
-    const ContextStackHash &hash = context_stack.hash();
-    destruct_ptr<T> &value = map_.lookup_or_add_cb(hash,
-                                                   [&]() { return allocator_.construct<T>(); });
-    return *value;
-  }
-
-  const T *lookup_ptr(const ContextStack &context_stack) const
-  {
-    const ContextStackHash &hash = context_stack.hash();
-    const destruct_ptr<T> *value = map_.lookup_ptr(hash);
-    if (value != nullptr) {
-      return value->get();
-    }
-    return nullptr;
-  }
-
-  const T &lookup_or_default(const ContextStack &context_stack, const T &default_value) const
-  {
-    const T *value = this->lookup_ptr(context_stack);
-    if (value != nullptr) {
-      return *value;
-    }
-    return default_value;
-  }
-
-  T *lookup_ptr(const ContextStack &context_stack)
-  {
-    return const_cast<T *>(const_cast<const ContextStackMap *>(this)->lookup_ptr(context_stack));
-  }
-};
-
-}  // namespace blender
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index 480b4b34097..ad83ad3077a 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -435,7 +435,6 @@ if(WITH_GTESTS)
     tests/BLI_bounds_test.cc
     tests/BLI_color_test.cc
     tests/BLI_cpp_type_test.cc
-    tests/BLI_context_stack_test.cc
     tests/BLI_delaunay_2d_test.cc
     tests/BLI_disjoint_set_test.cc
     tests/BLI_edgehash_test.cc
diff --git a/source/blender/blenlib/tests/BLI_context_stack_test.cc b/source/blender/blenlib/tests/BLI_context_stack_test.cc
deleted file mode 100644
index 570f2355ccc..00000000000
--- a/source/blender/blenlib/tests/BLI_context_stack_test.cc
+++ /dev/null
@@ -1,77 +0,0 @@
-/* SPDX-License-Identifier: Apache-2.0 */
-
-#include "BLI_context_stack.hh"
-#include "BLI_context_stack_map.hh"
-
-#include "testing/testing.h"
-
-namespace blender::tests {
-
-class NamedContext : public ContextStack {
- private:
-  static constexpr const char *s_static_type = "NAMED";
-  std::string name_;
-
- public:
-  NamedContext(const ContextStack *parent, std::string name)
-      : ContextStack(s_static_type, parent), name_(std::move(name))
-  {
-    hash_.mix_in(s_static_type, strlen(s_static_type));
-    hash_.mix_in(name_.data(), name_.size());
-  }
-
- private:
-  void print_current_in_line(std::ostream &stream) const override
-  {
-    stream << "Named: " << name_;
-  }
-};
-
-class IndexContext : public ContextStack {
- private:
-  static constexpr const char *s_static_type = "INDEX";
-  int64_t index_;
-
- public:
-  IndexContext(const ContextStack *parent, const int64_t index)
-      : ContextStack(s_static_type, parent), index_(index)
-  {
-    hash_.mix_in(s_static_type, strlen(s_static_type));
-    hash_.mix_in(&index_, sizeof(index_));
-  }
-
- private:
-  void print_current_in_line(std::ostream &stream) const override
-  {
-    stream << "Index: " << index_;
-  }
-};
-
-TEST(context_stack, Basic)
-{
-  ContextStackMap<int> map;
-
-  {
-    const NamedContext a{nullptr, "First"};
-    const NamedContext b{&a, "Second"};
-    const NamedContext c{&b, "Third"};
-    const IndexContext d1{&c, 42};
-    const IndexContext d2{&a, 100};
-
-    map.lookup_or_add(b) = 10;
-    map.lookup_or_add(d1) = 123;
-  }
-  {
-    const NamedContext a{nullptr, "First"};
-    const NamedContext b{&a, "Second"};
-    const NamedContext c{&b, "Third"};
-    const IndexContext d1{&c, 42};
-    const IndexContext d2{&a, 100};
-    const std::array<const ContextStack *, 5> elements = {&a, &b, &c, &d1, &d2};
-    for (const ContextStack *v : elements) {
-      v->print_stack(std::cout, std::to_string(map.lookup_or_default(*v, -1)));
-    }
-  }
-}
-
-}  // namespace blender::tests
diff --git a/source/blender/nodes/NOD_geometry_nodes_log.hh b/source/blender/nodes/NOD_geometry_nodes_log.hh
index 876ad5ae802..eebde2a7c85 100644
--- a/source/blender/nodes/NOD_geometry_nodes_log.hh
+++ b/source/blender/nodes/NOD_geometry_nodes_log.hh
@@ -4,7 +4,7 @@
 
 #include <chrono>
 
-#include "BLI_context_stack_map.hh"
+#include "BLI_context_stack.hh"
 #include "BLI_enumerable_thread_specific.hh"
 #include "BLI_generic_pointer.hh"
 #include "BLI_multi_value_map.hh"



More information about the Bf-blender-cvs mailing list