[Bf-blender-cvs] [d9fc988] master: Optimize reading of fcurves

Sergey Sharybin noreply at git.blender.org
Sat Aug 8 22:20:39 CEST 2015


Commit: d9fc9882dcce987bdcdb1aa6dafa82f8db77f177
Author: Sergey Sharybin
Date:   Sat Aug 8 22:17:03 2015 +0200
Branches: master
https://developer.blender.org/rBd9fc9882dcce987bdcdb1aa6dafa82f8db77f177

Optimize reading of fcurves

Reading fcurves wasn't really optimal because restoring fcu->group pointer was
changing lasthit pointer, which required full lookup over the oldnewmap happened
at the next call to newdatadr().

This reduces loading franck_sheep.blend file from ~2.2sec to 1.5sec.

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

M	source/blender/blenloader/intern/readfile.c

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

diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index ff7be0e..f37d24f 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -1239,6 +1239,31 @@ static void *newdataadr(FileData *fd, void *adr)		/* only direct databocks */
 	return oldnewmap_lookup_and_inc(fd->datamap, adr, true);
 }
 
+/* This is a special version of newdataadr() which allows us to keep lasthit of
+ * map unchanged. In certain cases this makes file loading time significantly
+ * faster.
+ *
+ * Use this function in cases like restoring pointer from one list element to
+ * another list element, but keep lasthit value so we can continue restoring
+ * pointers efficiently.
+ *
+ * Example of this could be found in direct_link_fcurves() which restores the
+ * fcurve group pointer and keeps lasthit optimal for linking all further
+ * fcurves.
+ */
+static void *newdataadr_ex(FileData *fd, void *adr, bool increase_lasthit)		/* only direct databocks */
+{
+	if (increase_lasthit) {
+		return newdataadr(fd, adr);
+	}
+	else {
+		int lasthit = fd->datamap->lasthit;
+		void *newadr = newdataadr(fd, adr);
+		fd->datamap->lasthit = lasthit;
+		return newadr;
+	}
+}
+
 static void *newdataadr_no_us(FileData *fd, void *adr)		/* only direct databocks */
 {
 	return oldnewmap_lookup_and_inc(fd->datamap, adr, false);
@@ -2219,7 +2244,7 @@ static void direct_link_fcurves(FileData *fd, ListBase *list)
 		fcu->rna_path = newdataadr(fd, fcu->rna_path);
 		
 		/* group */
-		fcu->grp = newdataadr(fd, fcu->grp);
+		fcu->grp = newdataadr_ex(fd, fcu->grp, false);
 		
 		/* clear disabled flag - allows disabled drivers to be tried again ([#32155]),
 		 * but also means that another method for "reviving disabled F-Curves" exists




More information about the Bf-blender-cvs mailing list