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:
authorCampbell Barton <ideasman42@gmail.com>2016-07-12 05:53:49 +0300
committerCampbell Barton <ideasman42@gmail.com>2016-07-12 06:03:04 +0300
commit0708b9aba8f7da87c4cf97b96c0bc9229fa9689c (patch)
tree63588657c286dfeb0d0ce99b64c16dbfbbd93213 /source/blender/makesdna/intern
parent4db1db327a0613abee950ffe12b013afdec2c111 (diff)
writefile: reuse SDNA between writes
Avoids decoding the SDNA string every undo step.
Diffstat (limited to 'source/blender/makesdna/intern')
-rw-r--r--source/blender/makesdna/intern/dna_genfile.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c
index f1d48c07de1..1e3c91d5ddc 100644
--- a/source/blender/makesdna/intern/dna_genfile.c
+++ b/source/blender/makesdna/intern/dna_genfile.c
@@ -605,6 +605,30 @@ SDNA *DNA_sdna_from_data(
}
}
+/**
+ * Using globals is acceptable here, the data is read-only and only changes between Blender versions.
+ *
+ * So it is safe to create once and reuse.
+ */
+static SDNA *g_sdna = NULL;
+
+void DNA_sdna_current_init(void)
+{
+ g_sdna = DNA_sdna_from_data(DNAstr, DNAlen, false, false, NULL);
+}
+
+const struct SDNA *DNA_sdna_current_get(void)
+{
+ BLI_assert(g_sdna != NULL);
+ return g_sdna;
+}
+
+void DNA_sdna_current_free(void)
+{
+ DNA_sdna_free(g_sdna);
+ g_sdna = NULL;
+}
+
/* ******************** END READ DNA ********************** */
/* ******************* HANDLE DNA ***************** */