diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-04-20 13:19:14 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-04-20 13:21:11 +0300 |
commit | 89bdc208d146eaf08f90c3dec2eb92f66b933d00 (patch) | |
tree | 242c726e6f482b047211ec874c3cb79f11590f3f /source/blender/makesrna/intern/rna_access.c | |
parent | 03a916e5b5abbdec8b5e0ccb7883986994e20108 (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.
Diffstat (limited to 'source/blender/makesrna/intern/rna_access.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 24 |
1 files changed, 19 insertions, 5 deletions
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); |