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:
authorJulian Eisel <julian@blender.org>2022-08-18 23:37:52 +0300
committerJulian Eisel <julian@blender.org>2022-08-19 23:21:04 +0300
commit8115d31248cab167e3142c975154d8f92d3beafd (patch)
treea9aae17207d57001d87641576dda3f4fd512c011 /source/blender/blenkernel/BKE_outliner_treehash.hh
parent6b9209ddfab375c55b73c11ac798b76345b822a0 (diff)
Outliner: (Refactor) Use C++ map instead of GHash
This container is type safe and contains a few nice optimizations, although they shouldn't make a big difference here in practice. The hashing now uses our default hashing method which reduces code complexity and seems to perform slightly better in my tests. For a Heist shot with a highly complex library overrides hierarchy in the Outliner this reduces the tree building time from around 25 to 23.6 seconds here. However the main design change for performance is yet to come, all this is just general code refactoring (which at least shouldn't make performance worse).
Diffstat (limited to 'source/blender/blenkernel/BKE_outliner_treehash.hh')
-rw-r--r--source/blender/blenkernel/BKE_outliner_treehash.hh25
1 files changed, 23 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_outliner_treehash.hh b/source/blender/blenkernel/BKE_outliner_treehash.hh
index b5226f7ed50..7f1dad5fd68 100644
--- a/source/blender/blenkernel/BKE_outliner_treehash.hh
+++ b/source/blender/blenkernel/BKE_outliner_treehash.hh
@@ -13,15 +13,33 @@
#include <memory>
+#include "BLI_map.hh"
+
struct BLI_mempool;
struct ID;
-struct GHash;
struct TreeStoreElem;
namespace blender::bke::outliner::treehash {
+/* -------------------------------------------------------------------- */
+
+class TreeStoreElemKey {
+ public:
+ ID *id = nullptr;
+ short type = 0;
+ short nr = 0;
+
+ explicit TreeStoreElemKey(const TreeStoreElem &elem);
+ TreeStoreElemKey(ID *id, short type, short nr);
+
+ uint64_t hash() const;
+ friend bool operator==(const TreeStoreElemKey &a, const TreeStoreElemKey &b);
+};
+
+/* -------------------------------------------------------------------- */
+
class TreeHash {
- GHash *treehash_ = nullptr;
+ Map<TreeStoreElemKey, std::unique_ptr<class TseGroup>> elem_groups_;
public:
~TreeHash();
@@ -49,6 +67,9 @@ class TreeHash {
private:
TreeHash() = default;
+ TseGroup *lookup_group(const TreeStoreElemKey &key) const;
+ TseGroup *lookup_group(const TreeStoreElem &elem) const;
+ TseGroup *lookup_group(short type, short nr, ID *id) const;
void fill_treehash(BLI_mempool &treestore);
};