Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/blenkernel/BKE_node_ui_storage.hh4
-rw-r--r--source/blender/blenlib/BLI_hash.hh27
-rw-r--r--source/blender/blenlib/BLI_user_counter.hh2
-rw-r--r--source/blender/blenlib/intern/math_vec.cc2
-rw-r--r--source/blender/blenlib/intern/mesh_boolean.cc5
-rw-r--r--source/blender/functions/FN_cpp_type.hh2
-rw-r--r--source/blender/functions/FN_cpp_type_make.hh2
-rw-r--r--source/blender/functions/FN_multi_function.hh2
-rw-r--r--source/blender/functions/FN_multi_function_builder.hh2
-rw-r--r--source/blender/functions/FN_multi_function_data_type.hh2
-rw-r--r--source/blender/nodes/NOD_derived_node_tree.hh5
11 files changed, 34 insertions, 21 deletions
diff --git a/source/blender/blenkernel/BKE_node_ui_storage.hh b/source/blender/blenkernel/BKE_node_ui_storage.hh
index a8fdbec1e8c..aa7e5180b03 100644
--- a/source/blender/blenkernel/BKE_node_ui_storage.hh
+++ b/source/blender/blenkernel/BKE_node_ui_storage.hh
@@ -58,9 +58,7 @@ class NodeTreeEvaluationContext {
uint64_t hash() const
{
- const uint64_t hash1 = blender::DefaultHash<std::string>{}(object_name_);
- const uint64_t hash2 = BLI_session_uuid_hash_uint64(&modifier_session_uuid_);
- return hash1 ^ (hash2 * 33); /* Copied from DefaultHash for std::pair. */
+ return blender::get_default_hash_2(object_name_, modifier_session_uuid_);
}
friend bool operator==(const NodeTreeEvaluationContext &a, const NodeTreeEvaluationContext &b)
diff --git a/source/blender/blenlib/BLI_hash.hh b/source/blender/blenlib/BLI_hash.hh
index 39695b110b1..4022c2baa1f 100644
--- a/source/blender/blenlib/BLI_hash.hh
+++ b/source/blender/blenlib/BLI_hash.hh
@@ -206,19 +206,38 @@ template<typename T> struct DefaultHash<T *> {
}
};
+template<typename T> uint64_t get_default_hash(const T &v)
+{
+ return DefaultHash<T>{}(v);
+}
+
+template<typename T1, typename T2> uint64_t get_default_hash_2(const T1 &v1, const T2 &v2)
+{
+ const uint64_t h1 = get_default_hash(v1);
+ const uint64_t h2 = get_default_hash(v2);
+ return h1 ^ (h2 * 19349669);
+}
+
+template<typename T1, typename T2, typename T3>
+uint64_t get_default_hash_3(const T1 &v1, const T2 &v2, const T3 &v3)
+{
+ const uint64_t h1 = get_default_hash(v1);
+ const uint64_t h2 = get_default_hash(v2);
+ const uint64_t h3 = get_default_hash(v3);
+ return h1 ^ (h2 * 19349669) ^ (h3 * 83492791);
+}
+
template<typename T> struct DefaultHash<std::unique_ptr<T>> {
uint64_t operator()(const std::unique_ptr<T> &value) const
{
- return DefaultHash<T *>{}(value.get());
+ return get_default_hash(value.get());
}
};
template<typename T1, typename T2> struct DefaultHash<std::pair<T1, T2>> {
uint64_t operator()(const std::pair<T1, T2> &value) const
{
- uint64_t hash1 = DefaultHash<T1>{}(value.first);
- uint64_t hash2 = DefaultHash<T2>{}(value.second);
- return hash1 ^ (hash2 * 33);
+ return get_default_hash_2(value.first, value.second);
}
};
diff --git a/source/blender/blenlib/BLI_user_counter.hh b/source/blender/blenlib/BLI_user_counter.hh
index ef276814981..3e6d5af4c3f 100644
--- a/source/blender/blenlib/BLI_user_counter.hh
+++ b/source/blender/blenlib/BLI_user_counter.hh
@@ -125,7 +125,7 @@ template<typename T> class UserCounter {
uint64_t hash() const
{
- return DefaultHash<T *>{}(data_);
+ return get_default_hash(data_);
}
friend bool operator==(const UserCounter &a, const UserCounter &b)
diff --git a/source/blender/blenlib/intern/math_vec.cc b/source/blender/blenlib/intern/math_vec.cc
index 1d138d0b0f4..223c0e273f0 100644
--- a/source/blender/blenlib/intern/math_vec.cc
+++ b/source/blender/blenlib/intern/math_vec.cc
@@ -173,7 +173,7 @@ mpq3 mpq3::cross_poly(Span<mpq3> poly)
uint64_t hash_mpq_class(const mpq_class &value)
{
/* TODO: better/faster implementation of this. */
- return DefaultHash<float>{}(static_cast<float>(value.get_d()));
+ return get_default_hash(static_cast<float>(value.get_d()));
}
uint64_t mpq2::hash() const
diff --git a/source/blender/blenlib/intern/mesh_boolean.cc b/source/blender/blenlib/intern/mesh_boolean.cc
index bc12ff1a652..bf70b044d0d 100644
--- a/source/blender/blenlib/intern/mesh_boolean.cc
+++ b/source/blender/blenlib/intern/mesh_boolean.cc
@@ -97,10 +97,7 @@ class Edge {
uint64_t hash() const
{
- constexpr uint64_t h1 = 33;
- uint64_t v0hash = DefaultHash<int>{}(v_[0]->id);
- uint64_t v1hash = DefaultHash<int>{}(v_[1]->id);
- return v0hash ^ (v1hash * h1);
+ return get_default_hash_2(v_[0]->id, v_[1]->id);
}
};
diff --git a/source/blender/functions/FN_cpp_type.hh b/source/blender/functions/FN_cpp_type.hh
index 665296f30e1..faf444e91f6 100644
--- a/source/blender/functions/FN_cpp_type.hh
+++ b/source/blender/functions/FN_cpp_type.hh
@@ -661,7 +661,7 @@ class CPPType : NonCopyable, NonMovable {
uint64_t hash() const
{
- return DefaultHash<const CPPType *>{}(this);
+ return get_default_hash(this);
}
template<typename T> bool is() const
diff --git a/source/blender/functions/FN_cpp_type_make.hh b/source/blender/functions/FN_cpp_type_make.hh
index 342161d01b6..cd14fe8c078 100644
--- a/source/blender/functions/FN_cpp_type_make.hh
+++ b/source/blender/functions/FN_cpp_type_make.hh
@@ -220,7 +220,7 @@ template<typename T> bool is_equal_cb(const void *a, const void *b)
template<typename T> uint64_t hash_cb(const void *value)
{
const T &value_ = *static_cast<const T *>(value);
- return DefaultHash<T>{}(value_);
+ return get_default_hash(value_);
}
} // namespace blender::fn::cpp_type_util
diff --git a/source/blender/functions/FN_multi_function.hh b/source/blender/functions/FN_multi_function.hh
index 2ce65426245..f6c4addfb52 100644
--- a/source/blender/functions/FN_multi_function.hh
+++ b/source/blender/functions/FN_multi_function.hh
@@ -64,7 +64,7 @@ class MultiFunction {
virtual uint64_t hash() const
{
- return DefaultHash<const MultiFunction *>{}(this);
+ return get_default_hash(this);
}
virtual bool equals(const MultiFunction &UNUSED(other)) const
diff --git a/source/blender/functions/FN_multi_function_builder.hh b/source/blender/functions/FN_multi_function_builder.hh
index 95a9f52e29e..691abeb18c0 100644
--- a/source/blender/functions/FN_multi_function_builder.hh
+++ b/source/blender/functions/FN_multi_function_builder.hh
@@ -384,7 +384,7 @@ template<typename T> class CustomMF_Constant : public MultiFunction {
uint64_t hash() const override
{
- return DefaultHash<T>{}(value_);
+ return get_default_hash(value_);
}
bool equals(const MultiFunction &other) const override
diff --git a/source/blender/functions/FN_multi_function_data_type.hh b/source/blender/functions/FN_multi_function_data_type.hh
index 713f73c2b5a..c3372151a1b 100644
--- a/source/blender/functions/FN_multi_function_data_type.hh
+++ b/source/blender/functions/FN_multi_function_data_type.hh
@@ -110,7 +110,7 @@ class MFDataType {
uint64_t hash() const
{
- return DefaultHash<CPPType>{}(*type_) + static_cast<uint64_t>(category_);
+ return get_default_hash_2(*type_, category_);
}
};
diff --git a/source/blender/nodes/NOD_derived_node_tree.hh b/source/blender/nodes/NOD_derived_node_tree.hh
index e47774bb25a..c29de611e18 100644
--- a/source/blender/nodes/NOD_derived_node_tree.hh
+++ b/source/blender/nodes/NOD_derived_node_tree.hh
@@ -261,7 +261,7 @@ inline const NodeRef *DNode::operator->() const
inline uint64_t DNode::hash() const
{
- return DefaultHash<const DTreeContext *>{}(context_) ^ DefaultHash<const NodeRef *>{}(node_ref_);
+ return get_default_hash_2(context_, node_ref_);
}
/* --------------------------------------------------------------------
@@ -316,8 +316,7 @@ inline const SocketRef *DSocket::operator->() const
inline uint64_t DSocket::hash() const
{
- return DefaultHash<const DTreeContext *>{}(context_) ^
- DefaultHash<const SocketRef *>{}(socket_ref_);
+ return get_default_hash_2(context_, socket_ref_);
}
/* --------------------------------------------------------------------