From db4fe8e3223b36615e53cf64f4a55f6d974c4597 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 30 Jun 2021 15:19:35 +0200 Subject: BlenRead: Add GHash-based search for already read linked IDs. Ths commit adds a new `IDNameLibMap` to `Main`, used during file reading to quickly find already read linked IDs. Without that, search would use string-based search over list of linked data, which becomes extremely slow and inneficient in cases where a lot of IDs are linked from a same library. See also {T89194}. Extrem-usecase reported in T89194 is now about 4 times faster in linked data reading (about 2 times faster for the whole .blend file loading). More normal cases (like Sprites studio production files) have barely measurable speed improvements, a few percents at best. NOTE: `main_idmap` API was extended to support insertion and removal of IDs from the mapping, avoids having to re-create the whole thing several time during libraries expansion in readcode. Differential Revision: https://developer.blender.org/D11757 --- source/blender/blenkernel/BKE_main.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/blender/blenkernel/BKE_main.h') diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h index ed930fe539d..ae60a5563b5 100644 --- a/source/blender/blenkernel/BKE_main.h +++ b/source/blender/blenkernel/BKE_main.h @@ -48,6 +48,7 @@ struct BLI_mempool; struct BlendThumbnail; struct GHash; struct GSet; +struct IDNameLib_Map; struct ImBuf; struct Library; struct MainLock; @@ -191,6 +192,9 @@ typedef struct Main { */ struct MainIDRelations *relations; + /* IDMap of IDs. Currently used when reading (expanding) libraries. */ + struct IDNameLib_Map *id_map; + struct MainLock *lock; } Main; -- cgit v1.2.3