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 <montagne29@wanadoo.fr>2018-04-20 13:19:14 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-04-20 13:21:11 +0300
commit89bdc208d146eaf08f90c3dec2eb92f66b933d00 (patch)
tree242c726e6f482b047211ec874c3cb79f11590f3f
parent03a916e5b5abbdec8b5e0ccb7883986994e20108 (diff)
Static overrides optimization: 30% quicker.
use stack instead of always allocating memory for RNA paths of checked properties! From average 167ms to 118ms here with Autumn rig... Still a lot to improve, but that's already much better.
-rw-r--r--source/blender/blenkernel/intern/library_override.c2
-rw-r--r--source/blender/makesrna/intern/rna_access.c24
2 files changed, 20 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/library_override.c b/source/blender/blenkernel/intern/library_override.c
index 653a590e7f2..625af190bbc 100644
--- a/source/blender/blenkernel/intern/library_override.c
+++ b/source/blender/blenkernel/intern/library_override.c
@@ -510,7 +510,7 @@ bool BKE_override_static_status_check_reference(ID *local)
* all properties in depth (all overridable ones at least). Generating diff values and applying overrides
* are much cheaper.
*
- * \return true is new overriding op was created, or some local data was reset. */
+ * \return true if new overriding op was created, or some local data was reset. */
bool BKE_override_static_operations_create(ID *local, const bool force_auto)
{
BLI_assert(local->override_static != NULL);
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index a9a83c6d37b..42eb7b81c37 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -7503,15 +7503,25 @@ bool RNA_struct_override_matches(
continue;
}
+#define RNA_PATH_BUFFSIZE 8192
+#define RNA_PATH_PRINTF(_str, ...) \
+ if (BLI_snprintf(rna_path, RNA_PATH_BUFFSIZE, \
+ (_str), __VA_ARGS__) >= RNA_PATH_BUFFSIZE) \
+ { rna_path = BLI_sprintfN((_str), __VA_ARGS__); }(void)0
+#define RNA_PATH_FREE \
+ if (rna_path != rna_path_buffer) MEM_freeN(rna_path)
+
+ char rna_path_buffer[RNA_PATH_BUFFSIZE];
+ char *rna_path = rna_path_buffer;
+
/* XXX TODO this will have to be refined to handle collections insertions, and array items */
- char *rna_path;
if (root_path) {
/* Inlined building, much much more efficient. */
if (prop_local->magic == RNA_MAGIC) {
- rna_path = BLI_sprintfN("%s.%s", root_path, RNA_property_identifier(prop_local));
+ RNA_PATH_PRINTF("%s.%s", root_path, RNA_property_identifier(prop_local));
}
else {
- rna_path = BLI_sprintfN("%s[\"%s\"]", root_path, RNA_property_identifier(prop_local));
+ RNA_PATH_PRINTF("%s[\"%s\"]", root_path, RNA_property_identifier(prop_local));
}
}
else {
@@ -7524,7 +7534,7 @@ bool RNA_struct_override_matches(
// printf("Override Checking %s\n", rna_path);
if (ignore_overridden && BKE_override_static_property_find(override, rna_path) != NULL) {
- MEM_SAFE_FREE(rna_path);
+ RNA_PATH_FREE;
continue;
}
@@ -7577,7 +7587,11 @@ bool RNA_struct_override_matches(
}
}
- MEM_SAFE_FREE(rna_path);
+ RNA_PATH_FREE;
+
+#undef RNA_PATH_BUFFSIZE
+#undef RNA_PATH_PRINTF
+#undef RNA_PATH_FREE
}
RNA_property_collection_end(&iter);