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-29 12:37:19 +0300
committerJacques Lucke <jacques@blender.org>2020-04-29 12:37:19 +0300
commit157f8364935402aed8024a2bd90348662fbb49b3 (patch)
treed87c08fd3d191d478ce50a321fdf54c6aaf1d7a7 /source/blender/depsgraph
parent657188c1a240eececd4aec95f97fe1b96c140070 (diff)
Depsgraph: use native BLI data structures in registry
Reviewers: sergey Differential Revision: https://developer.blender.org/D7559
Diffstat (limited to 'source/blender/depsgraph')
-rw-r--r--source/blender/depsgraph/intern/depsgraph_registry.cc35
-rw-r--r--source/blender/depsgraph/intern/depsgraph_registry.h2
-rw-r--r--source/blender/depsgraph/intern/depsgraph_type.h2
3 files changed, 14 insertions, 25 deletions
diff --git a/source/blender/depsgraph/intern/depsgraph_registry.cc b/source/blender/depsgraph/intern/depsgraph_registry.cc
index ad60b1bc4cf..3b0a0b3ea19 100644
--- a/source/blender/depsgraph/intern/depsgraph_registry.cc
+++ b/source/blender/depsgraph/intern/depsgraph_registry.cc
@@ -29,46 +29,33 @@
namespace DEG {
-typedef set<Depsgraph *> DepsgraphStorage;
-typedef map<Main *, DepsgraphStorage> MainDepsgraphMap;
-
-static MainDepsgraphMap g_graph_registry;
+static Map<Main *, VectorSet<Depsgraph *>> g_graph_registry;
void register_graph(Depsgraph *depsgraph)
{
Main *bmain = depsgraph->bmain;
- MainDepsgraphMap::iterator it = g_graph_registry.find(bmain);
- if (it == g_graph_registry.end()) {
- it = g_graph_registry.insert(make_pair(bmain, DepsgraphStorage())).first;
- }
- DepsgraphStorage &storage = it->second;
- storage.insert(depsgraph);
+ g_graph_registry.lookup_or_add_default(bmain).add_new(depsgraph);
}
void unregister_graph(Depsgraph *depsgraph)
{
Main *bmain = depsgraph->bmain;
- MainDepsgraphMap::iterator it = g_graph_registry.find(bmain);
- BLI_assert(it != g_graph_registry.end());
-
- // Remove dependency graph from storage.
- DepsgraphStorage &storage = it->second;
- storage.erase(depsgraph);
+ VectorSet<Depsgraph *> &graphs = g_graph_registry.lookup(bmain);
+ graphs.remove(depsgraph);
// If this was the last depsgraph associated with the main, remove the main entry as well.
- if (storage.empty()) {
- g_graph_registry.erase(bmain);
+ if (graphs.is_empty()) {
+ g_graph_registry.remove(bmain);
}
}
-const set<Depsgraph *> &get_all_registered_graphs(Main *bmain)
+ArrayRef<Depsgraph *> get_all_registered_graphs(Main *bmain)
{
- MainDepsgraphMap::iterator it = g_graph_registry.find(bmain);
- if (it == g_graph_registry.end()) {
- static DepsgraphStorage empty_storage;
- return empty_storage;
+ VectorSet<Depsgraph *> *graphs = g_graph_registry.lookup_ptr(bmain);
+ if (graphs != nullptr) {
+ return *graphs;
}
- return it->second;
+ return {};
}
} // namespace DEG
diff --git a/source/blender/depsgraph/intern/depsgraph_registry.h b/source/blender/depsgraph/intern/depsgraph_registry.h
index 7517b6a0b2a..f8e5b9543f2 100644
--- a/source/blender/depsgraph/intern/depsgraph_registry.h
+++ b/source/blender/depsgraph/intern/depsgraph_registry.h
@@ -33,6 +33,6 @@ struct Depsgraph;
void register_graph(Depsgraph *depsgraph);
void unregister_graph(Depsgraph *depsgraph);
-const set<Depsgraph *> &get_all_registered_graphs(Main *bmain);
+ArrayRef<Depsgraph *> get_all_registered_graphs(Main *bmain);
} // namespace DEG
diff --git a/source/blender/depsgraph/intern/depsgraph_type.h b/source/blender/depsgraph/intern/depsgraph_type.h
index 6417f49e1ae..7016d07ae72 100644
--- a/source/blender/depsgraph/intern/depsgraph_type.h
+++ b/source/blender/depsgraph/intern/depsgraph_type.h
@@ -44,6 +44,7 @@
#include "BLI_set.hh"
#include "BLI_string_ref.hh"
#include "BLI_vector.hh"
+#include "BLI_vector_set.hh"
struct Depsgraph;
@@ -58,6 +59,7 @@ using BLI::Set;
using BLI::StringRef;
using BLI::StringRefNull;
using BLI::Vector;
+using BLI::VectorSet;
using std::deque;
using std::map;
using std::pair;