From 0852d13bbdd4b0394f4ff9d051959c7b731977b7 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 10 Jun 2020 15:23:22 +0200 Subject: Depsgraph: use native Set data structure Differential Revision: https://developer.blender.org/D7982 --- .../depsgraph/intern/builder/deg_builder_cache.cc | 21 +++++++++++---------- .../depsgraph/intern/builder/deg_builder_cache.h | 5 ++++- source/blender/depsgraph/intern/depsgraph_build.cc | 6 +++--- 3 files changed, 18 insertions(+), 14 deletions(-) (limited to 'source/blender/depsgraph/intern') 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 animated_properties_set; + Set animated_properties_set; }; typedef map 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 ids_; + Set ids_; }; class DepsgraphFromIDsNodeBuilder : public DepsgraphNodeBuilder { -- cgit v1.2.3