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.
This commit is contained in:
parent
cc0bbc28e2
commit
d9fc9882dc
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue