diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2019-12-19 23:58:59 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2019-12-20 16:29:35 +0300 |
commit | 46607bc09d5cd9fa3570e5ad4b01ea4ea7adaffc (patch) | |
tree | 7a1b14466e1de6744031c7dfc3ca25711d363ea3 /source/blender/windowmanager/intern/wm_files_link.c | |
parent | 4cc8201a651007b7308a4468a550dbbd97c6c346 (diff) |
ID Management: Improve speed of code used when creating/renaming and ID.
This commit affects `id_sort_by_name()` and `check_for_dupid()` helper:
* Add a new parameter, `ID *id_sorting_hint`, to `id_sort_by_name()`,
and when non-NULL, check if we can insert `id` immediately before or
after it. This can dramatically reduce time spent in that function.
* Use loop over whole list in `check_for_dupid()` to also define the
likely ID pointer that will be neighbor with our new one.
This gives another decent speedup to all massive addition cases:
| Number and type of names of IDs | old code | new code | speed improvement |
| -------------------------------- | -------- | -------- | ----------------- |
| 40K, mixed (14k rand, 26k const) | 39s | 33s | 18% |
| 40K, fully random | 51s | 42s | 21% |
| 40K, fully constant | 40s | 34s | 18% |
Combined with the previous commits, this makes massive addition of IDs more
than twice as fast as previously.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_files_link.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_files_link.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c index 3374d17cbfd..f0b186761ce 100644 --- a/source/blender/windowmanager/intern/wm_files_link.c +++ b/source/blender/windowmanager/intern/wm_files_link.c @@ -828,7 +828,7 @@ static void lib_relocate_do(Main *bmain, BLI_strncpy(&old_id->name[len], "~000", 7); } - id_sort_by_name(which_libbase(bmain, GS(old_id->name)), old_id); + id_sort_by_name(which_libbase(bmain, GS(old_id->name)), old_id, NULL); BKE_reportf( reports, |