Depsgraph: use native Set data structure

Differential Revision: https://developer.blender.org/D7982
This commit is contained in:
2020-06-10 15:23:22 +02:00
parent 4fefe3ac3b
commit 0852d13bbd
3 changed files with 18 additions and 14 deletions

View File

@@ -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,

View File

@@ -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;

View File

@@ -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 {