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-04-28 12:37:44 +0300
committerJacques Lucke <jacques@blender.org>2020-04-28 12:39:49 +0300
commit7acc8a5a929b899bf0c0dd63bda4dd6b9c6c8aed (patch)
tree75326abfdf3f79e2b0628447475eda2033e3c015 /source/blender
parent0372121e17f734d55fc156b2afbedcc31242f362 (diff)
Depsgraph: Use BLI::Map for RNANodeQuery.id_data_map_
Reviewers: sergey Differential Revision: https://developer.blender.org/D7512
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_rna.cc24
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_rna.h2
-rw-r--r--source/blender/depsgraph/intern/depsgraph_type.h1
3 files changed, 6 insertions, 21 deletions
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
index 73f6730be03..8bd3dff482d 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
@@ -121,26 +121,13 @@ bool RNANodeIdentifier::is_valid() const
/* ********************************** Query ********************************* */
-namespace {
-
-void ghash_id_data_free_func(void *value)
-{
- RNANodeQueryIDData *id_data = static_cast<RNANodeQueryIDData *>(value);
- OBJECT_GUARDED_DELETE(id_data, RNANodeQueryIDData);
-}
-
-} // namespace
-
RNANodeQuery::RNANodeQuery(Depsgraph *depsgraph, DepsgraphBuilder *builder)
- : depsgraph_(depsgraph),
- builder_(builder),
- id_data_map_(BLI_ghash_ptr_new("rna node query id data hash"))
+ : depsgraph_(depsgraph), builder_(builder)
{
}
RNANodeQuery::~RNANodeQuery()
{
- BLI_ghash_free(id_data_map_, nullptr, ghash_id_data_free_func);
}
Node *RNANodeQuery::find_node(const PointerRNA *ptr,
@@ -384,12 +371,9 @@ RNANodeIdentifier RNANodeQuery::construct_node_identifier(const PointerRNA *ptr,
RNANodeQueryIDData *RNANodeQuery::ensure_id_data(const ID *id)
{
- RNANodeQueryIDData **id_data_ptr;
- if (!BLI_ghash_ensure_p(
- id_data_map_, const_cast<ID *>(id), reinterpret_cast<void ***>(&id_data_ptr))) {
- *id_data_ptr = OBJECT_GUARDED_NEW(RNANodeQueryIDData, id);
- }
- return *id_data_ptr;
+ unique_ptr<RNANodeQueryIDData> &id_data = id_data_map_.lookup_or_add(
+ id, [&]() { return BLI::make_unique<RNANodeQueryIDData>(id); });
+ return id_data.get();
}
} // namespace DEG
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.h b/source/blender/depsgraph/intern/builder/deg_builder_rna.h
index 8a79d9abef9..e7e9e883e85 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_rna.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.h
@@ -83,7 +83,7 @@ class RNANodeQuery {
DepsgraphBuilder *builder_;
/* Indexed by an ID, returns RNANodeQueryIDData associated with that ID. */
- GHash *id_data_map_;
+ Map<const ID *, unique_ptr<RNANodeQueryIDData>> id_data_map_;
/* Construct identifier of the node which corresponds given configuration
* of RNA property. */
diff --git a/source/blender/depsgraph/intern/depsgraph_type.h b/source/blender/depsgraph/intern/depsgraph_type.h
index a3dc2135f78..2b8b5471d0f 100644
--- a/source/blender/depsgraph/intern/depsgraph_type.h
+++ b/source/blender/depsgraph/intern/depsgraph_type.h
@@ -58,6 +58,7 @@ using std::map;
using std::pair;
using std::set;
using std::string;
+using std::unique_ptr;
using std::unordered_map;
using std::vector;