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-23 17:51:01 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-04-23 17:52:26 +0300
commit4498192813c334e824858ffd09b2926caa90b072 (patch)
tree243cdf4ef09e5a4c56c309744e1f05c87886c01f /source/blender/makesrna/intern/rna_rna.c
parentfc9624e485e17fa43e21931b1e5f2b5ec5211ab2 (diff)
Static Overrides: more performances improvements.
Moved another dynamic allocating print into (usually) static one, gives us another average 8% speedup on Autumn rig.
Diffstat (limited to 'source/blender/makesrna/intern/rna_rna.c')
-rw-r--r--source/blender/makesrna/intern/rna_rna.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c
index b16a5ce8baa..448d0882fb3 100644
--- a/source/blender/makesrna/intern/rna_rna.c
+++ b/source/blender/makesrna/intern/rna_rna.c
@@ -1160,14 +1160,6 @@ static int rna_property_override_diff_propptr(
}
}
-static char *rna_path_collection_prop_item_extend(const char *rna_path_prop, const char *item_name)
-{
- const size_t esc_item_name_len = strlen(item_name) * 2;
- char *esc_item_name = alloca(sizeof(*esc_item_name) * esc_item_name_len);
- BLI_strescape(esc_item_name, item_name, esc_item_name_len);
- return BLI_sprintfN("%s[\"%s\"]", rna_path_prop, esc_item_name);
-}
-
int rna_property_override_diff_default(PointerRNA *ptr_a, PointerRNA *ptr_b,
PropertyRNA *prop_a, PropertyRNA *prop_b,
const int len_a, const int len_b,
@@ -1436,8 +1428,6 @@ int rna_property_override_diff_default(PointerRNA *ptr_a, PointerRNA *ptr_b,
for (; iter_a.valid && iter_b.valid;
RNA_property_collection_next(&iter_a), RNA_property_collection_next(&iter_b), idx++)
{
- char *extended_rna_path = NULL;
-
if (iter_a.ptr.type != iter_b.ptr.type) {
/* nothing we can do (for until we support adding/removing from collections), skip it. */
equals = false;
@@ -1458,6 +1448,18 @@ int rna_property_override_diff_default(PointerRNA *ptr_a, PointerRNA *ptr_b,
propname_a = RNA_property_string_get_alloc(&iter_a.ptr, propname, propname_buff_a, sizeof(propname_buff_a), NULL);
propname_b = RNA_property_string_get_alloc(&iter_b.ptr, propname, propname_buff_b, sizeof(propname_buff_b), NULL);
}
+
+#define RNA_PATH_BUFFSIZE 8192
+#define RNA_PATH_PRINTF(_str, ...) \
+ if (BLI_snprintf(extended_rna_path_buffer, RNA_PATH_BUFFSIZE, \
+ (_str), __VA_ARGS__) >= RNA_PATH_BUFFSIZE) \
+ { extended_rna_path = BLI_sprintfN((_str), __VA_ARGS__); }(void)0
+#define RNA_PATH_FREE \
+ if (extended_rna_path != extended_rna_path_buffer) MEM_freeN(extended_rna_path)
+
+ char extended_rna_path_buffer[RNA_PATH_BUFFSIZE];
+ char *extended_rna_path = extended_rna_path_buffer;
+
/* There may be a propname defined in some cases, while no actual name set
* (e.g. happens with point cache), in that case too we want to fall back to index. */
if ((propname_a != NULL && propname_a[0] != '\0') || (propname_b != NULL && propname_b[0] != '\0')) {
@@ -1466,12 +1468,14 @@ int rna_property_override_diff_default(PointerRNA *ptr_a, PointerRNA *ptr_b,
equals = false;
}
else if (rna_path) {
- extended_rna_path = rna_path_collection_prop_item_extend(rna_path, propname_a);
+ char esc_item_name[RNA_PATH_BUFFSIZE];
+ BLI_strescape(esc_item_name, propname_a, RNA_PATH_BUFFSIZE);
+ RNA_PATH_PRINTF("%s[\"%s\"]", rna_path, esc_item_name);
}
}
else { /* Based on index... */
if (rna_path) {
- extended_rna_path = BLI_sprintfN("%s[%d]", rna_path, idx);
+ RNA_PATH_PRINTF("%s[%d]", rna_path, idx);
}
}
@@ -1489,11 +1493,15 @@ int rna_property_override_diff_default(PointerRNA *ptr_a, PointerRNA *ptr_b,
if (propname_b != propname_buff_b) {
MEM_SAFE_FREE(propname_b);
}
- MEM_SAFE_FREE(extended_rna_path);
+ RNA_PATH_FREE;
if (!rna_path && !equals) {
break; /* Early out in case we do not want to loop over whole collection. */
}
+
+#undef RNA_PATH_BUFFSIZE
+#undef RNA_PATH_PRINTF
+#undef RNA_PATH_FREE
}
equals = equals && !(iter_a.valid || iter_b.valid); /* Not same number of items in both collections... */