From 71feaba6576ea5c90a903752cdfd33dc7b59276c Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 13 Oct 2023 18:41:27 +0200 Subject: [PATCH] RNA: speedup rna path creation in simple but common case This speeds up saving the following production file by about 10%: `240ms -> 220ms` `heist/pro/shots/060_fight/060_0080/060_0080.anim.blend` This is a fairly low hanging fruit. Ideally we wouldn't have to duplicate the string at all, but changing that is a larger undertaking. --- source/blender/makesrna/intern/rna_path.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_path.cc b/source/blender/makesrna/intern/rna_path.cc index 4b3da0764c1..eefda8e3c5c 100644 --- a/source/blender/makesrna/intern/rna_path.cc +++ b/source/blender/makesrna/intern/rna_path.cc @@ -1098,7 +1098,13 @@ static char *rna_path_from_ptr_to_property_index_ex( } else { if (is_rna) { - path = BLI_sprintfN("%s%s", propname, index_str); + if (index_dim == 0) { + /* Use direct duplication instead of #BLI_sprintfN because it's faster. */ + path = BLI_strdup(propname); + } + else { + path = BLI_sprintfN("%s%s", propname, index_str); + } } else { char propname_esc[MAX_IDPROP_NAME * 2];