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:
authorJacques Lucke <jacques@blender.org>2020-06-10 16:23:22 +0300
committerJacques Lucke <jacques@blender.org>2020-06-10 16:24:03 +0300
commit0852d13bbdd4b0394f4ff9d051959c7b731977b7 (patch)
tree74ed0db7522aca2860d400842def02ebc17fb903
parent4fefe3ac3b8d8cd70d1f54e1be21f6455ce0d744 (diff)
Depsgraph: use native Set data structure
Differential Revision: https://developer.blender.org/D7982
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_cache.cc21
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_cache.h5
-rw-r--r--source/blender/depsgraph/intern/depsgraph_build.cc6
3 files changed, 18 insertions, 14 deletions
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_cache.cc b/source/blender/depsgraph/intern/builder/deg_builder_cache.cc
index ba0238b43c7..104676f7ab6 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_cache.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_cache.cc
@@ -66,15 +66,16 @@ AnimatedPropertyID::AnimatedPropertyID(ID * /*id*/,
property_rna = RNA_struct_type_find_property(type, property_name);
}
-bool AnimatedPropertyID::operator<(const AnimatedPropertyID &other) const
+bool operator==(const AnimatedPropertyID &a, const AnimatedPropertyID &b)
{
- if (data < other.data) {
- return true;
- }
- else if (data == other.data) {
- return property_rna < other.property_rna;
- }
- return false;
+ return a.data == b.data && a.property_rna == b.property_rna;
+}
+
+uint32_t AnimatedPropertyID::hash() const
+{
+ uintptr_t ptr1 = (uintptr_t)data;
+ uintptr_t ptr2 = (uintptr_t)property_rna;
+ return (uint32_t)(((ptr1 >> 4) * 33) ^ (ptr2 >> 4));
}
namespace {
@@ -126,7 +127,7 @@ void AnimatedPropertyStorage::initializeFromID(DepsgraphBuilderCache *builder_ca
void AnimatedPropertyStorage::tagPropertyAsAnimated(const AnimatedPropertyID &property_id)
{
- animated_properties_set.insert(property_id);
+ animated_properties_set.add(property_id);
}
void AnimatedPropertyStorage::tagPropertyAsAnimated(const PointerRNA *pointer_rna,
@@ -137,7 +138,7 @@ void AnimatedPropertyStorage::tagPropertyAsAnimated(const PointerRNA *pointer_rn
bool AnimatedPropertyStorage::isPropertyAnimated(const AnimatedPropertyID &property_id)
{
- return animated_properties_set.find(property_id) != animated_properties_set.end();
+ return animated_properties_set.contains(property_id);
}
bool AnimatedPropertyStorage::isPropertyAnimated(const PointerRNA *pointer_rna,
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_cache.h b/source/blender/depsgraph/intern/builder/deg_builder_cache.h
index 949020e3a81..bb4e1f5c96a 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_cache.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_cache.h
@@ -44,7 +44,10 @@ class AnimatedPropertyID {
AnimatedPropertyID(ID *id, StructRNA *type, const char *property_name);
AnimatedPropertyID(ID *id, StructRNA *type, void *data, const char *property_name);
+ uint32_t hash() const;
+
bool operator<(const AnimatedPropertyID &other) const;
+ friend bool operator==(const AnimatedPropertyID &a, const AnimatedPropertyID &b);
/* Corresponds to PointerRNA.data. */
void *data;
@@ -67,7 +70,7 @@ class AnimatedPropertyStorage {
bool is_fully_initialized;
/* indexed by PointerRNA.data. */
- set<AnimatedPropertyID> animated_properties_set;
+ Set<AnimatedPropertyID> animated_properties_set;
};
typedef map<ID *, AnimatedPropertyStorage *> AnimatedPropertyStorageMap;
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc
index 9e50bd87d6c..cdaf68cb826 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build.cc
@@ -357,17 +357,17 @@ class DepsgraphFromIDsFilter {
DepsgraphFromIDsFilter(ID **ids, const int num_ids)
{
for (int i = 0; i < num_ids; ++i) {
- ids_.insert(ids[i]);
+ ids_.add(ids[i]);
}
}
bool contains(ID *id)
{
- return ids_.find(id) != ids_.end();
+ return ids_.contains(id);
}
protected:
- set<ID *> ids_;
+ Set<ID *> ids_;
};
class DepsgraphFromIDsNodeBuilder : public DepsgraphNodeBuilder {