[Bf-blender-cvs] [89bdc208d14] blender2.8: Static overrides optimization: 30% quicker.

Bastien Montagne noreply at git.blender.org
Fri Apr 20 12:24:07 CEST 2018


Commit: 89bdc208d146eaf08f90c3dec2eb92f66b933d00
Author: Bastien Montagne
Date:   Fri Apr 20 12:19:14 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB89bdc208d146eaf08f90c3dec2eb92f66b933d00

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.

===================================================================

M	source/blender/blenkernel/intern/library_override.c
M	source/blender/makesrna/intern/rna_access.c

===================================================================

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);



More information about the Bf-blender-cvs mailing list