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:
authorBastien Montagne <b.mont29@gmail.com>2019-11-22 14:26:36 +0300
committerBastien Montagne <b.mont29@gmail.com>2019-11-22 14:26:36 +0300
commit2a38b857f7dc33150ff44ffda3366dbb197d5425 (patch)
treed5e634bf89b86a9d21ad692a1a6a1a42525e629f /source/blender/blenkernel/intern/library_override.c
parentcfb7f508ce76b8dea83da555e67813c161a6869d (diff)
LibOverride: Make diffing several times faster.
Diffing on undo steps is a critical performance point of override system, although not required for override itself, it gives user immediate feedback ove what is overridden. Profiling showed that rna path text search over overrides operations was by far the most costly thing here, so now using a runtime temp ghash mapping for this search instead. Seems to give at least 5 times speedup on big production rig.
Diffstat (limited to 'source/blender/blenkernel/intern/library_override.c')
-rw-r--r--source/blender/blenkernel/intern/library_override.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/library_override.c b/source/blender/blenkernel/intern/library_override.c
index 4f10a5bca6b..ae6d1c26a2b 100644
--- a/source/blender/blenkernel/intern/library_override.c
+++ b/source/blender/blenkernel/intern/library_override.c
@@ -36,6 +36,7 @@
#include "BKE_main.h"
#include "BLI_utildefines.h"
+#include "BLI_ghash.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
@@ -148,6 +149,10 @@ void BKE_override_library_clear(IDOverrideLibrary *override, const bool do_id_us
{
BLI_assert(override != NULL);
+ if (override->runtime != NULL) {
+ BLI_ghash_clear(override->runtime, NULL, NULL);
+ }
+
for (IDOverrideLibraryProperty *op = override->properties.first; op; op = op->next) {
bke_override_property_clear(op);
}
@@ -164,6 +169,11 @@ void BKE_override_library_free(struct IDOverrideLibrary **override, const bool d
{
BLI_assert(*override != NULL);
+ if ((*override)->runtime != NULL) {
+ BLI_ghash_free((*override)->runtime, NULL, NULL);
+ (*override)->runtime = NULL;
+ }
+
BKE_override_library_clear(*override, do_id_user);
MEM_freeN(*override);
*override = NULL;
@@ -285,15 +295,28 @@ bool BKE_override_library_create_from_tag(Main *bmain)
return ret;
}
+/* We only build override GHash on request. */
+BLI_INLINE IDOverrideLibraryRuntime *override_library_rna_path_mapping_ensure(
+ IDOverrideLibrary *override)
+{
+ if (override->runtime == NULL) {
+ override->runtime = BLI_ghash_new(BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, __func__);
+ for (IDOverrideLibraryProperty *op = override->properties.first; op != NULL; op = op->next) {
+ BLI_ghash_insert(override->runtime, op->rna_path, op);
+ }
+ }
+
+ return override->runtime;
+}
+
/**
* Find override property from given RNA path, if it exists.
*/
IDOverrideLibraryProperty *BKE_override_library_property_find(IDOverrideLibrary *override,
const char *rna_path)
{
- /* XXX TODO we'll most likely want a runtime ghash to store that mapping at some point. */
- return BLI_findstring_ptr(
- &override->properties, rna_path, offsetof(IDOverrideLibraryProperty, rna_path));
+ IDOverrideLibraryRuntime *override_runtime = override_library_rna_path_mapping_ensure(override);
+ return BLI_ghash_lookup(override_runtime, rna_path);
}
/**
@@ -303,7 +326,6 @@ IDOverrideLibraryProperty *BKE_override_library_property_get(IDOverrideLibrary *
const char *rna_path,
bool *r_created)
{
- /* XXX TODO we'll most likely want a runtime ghash to store that mapping at some point. */
IDOverrideLibraryProperty *op = BKE_override_library_property_find(override, rna_path);
if (op == NULL) {
@@ -311,6 +333,10 @@ IDOverrideLibraryProperty *BKE_override_library_property_get(IDOverrideLibrary *
op->rna_path = BLI_strdup(rna_path);
BLI_addtail(&override->properties, op);
+ IDOverrideLibraryRuntime *override_runtime = override_library_rna_path_mapping_ensure(
+ override);
+ BLI_ghash_insert(override_runtime, op->rna_path, op);
+
if (r_created) {
*r_created = true;
}
@@ -355,6 +381,9 @@ void BKE_override_library_property_delete(IDOverrideLibrary *override,
IDOverrideLibraryProperty *override_property)
{
bke_override_property_clear(override_property);
+ if (override->runtime != NULL) {
+ BLI_ghash_remove(override->runtime, override_property->rna_path, NULL, NULL);
+ }
BLI_freelinkN(&override->properties, override_property);
}