diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-08-08 23:17:03 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-08-08 23:17:03 +0300 |
commit | d9fc9882dcce987bdcdb1aa6dafa82f8db77f177 (patch) | |
tree | cb4929d779e05547c3d2e330d37ff68cec10bdef /source/blender | |
parent | cc0bbc28e2368f16eda53260d777098b962567ad (diff) |
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.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index ff7be0e1d58..f37d24f9681 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 |