From 3fb2c1e4a2f99d5de2326ab593c1d900e164e5bd Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 7 Jul 2016 21:18:04 +0200 Subject: Make use of new 'idtype can use idtype' check (in ID usages code, and ID remapping one too). Reduces calls to BKE_library_foreach_ID_link() from 312 to 105 when relocating a library in a rather simple lib reload test... --- source/blender/blenkernel/intern/library_query.c | 14 ++++++++++++-- source/blender/blenkernel/intern/library_remap.c | 4 ++++ 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c index afee80d5206..d068a394089 100644 --- a/source/blender/blenkernel/intern/library_query.c +++ b/source/blender/blenkernel/intern/library_query.c @@ -960,14 +960,19 @@ static bool library_ID_is_used(Main *bmain, void *idv, const bool check_linked) { IDUsersIter iter; ListBase *lb_array[MAX_LIBARRAY]; + ID *id = idv; int i = set_listbasepointers(bmain, lb_array); bool is_defined = false; - iter.id = idv; + iter.id = id; iter.count = 0; while (i-- && !is_defined) { ID *id_curr = lb_array[i]->first; + if (!id_curr || !BKE_library_idtype_can_use_idtype(GS(id->name), GS(id_curr->name))) { + continue; + } + for (; id_curr && !is_defined; id_curr = id_curr->next) { if (check_linked != ID_IS_LINKED_DATABLOCK(id_curr)) { continue; @@ -1007,14 +1012,19 @@ void BKE_library_ID_test_usages(Main *bmain, void *idv, bool *is_used_local, boo { IDUsersIter iter_local, iter_linked; ListBase *lb_array[MAX_LIBARRAY]; + ID *id = idv; int i = set_listbasepointers(bmain, lb_array); bool is_defined = false; - iter_local.id = iter_linked.id = idv; + iter_local.id = iter_linked.id = id; iter_local.count = iter_linked.count = 0; while (i-- && !is_defined) { ID *id_curr = lb_array[i]->first; + if (!id_curr || !BKE_library_idtype_can_use_idtype(GS(id->name), GS(id_curr->name))) { + continue; + } + for (; id_curr && !is_defined; id_curr = id_curr->next) { IDUsersIter *iter = (ID_IS_LINKED_DATABLOCK(id_curr)) ? &iter_linked : &iter_local; diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c index a290c1c8cf5..491994a9555 100644 --- a/source/blender/blenkernel/intern/library_remap.c +++ b/source/blender/blenkernel/intern/library_remap.c @@ -283,6 +283,10 @@ static void libblock_remap_data( while (i--) { ID *id_curr = lb_array[i]->first; + if (!id_curr || !BKE_library_idtype_can_use_idtype(GS(id_curr->name), GS(old_id->name))) { + continue; + } + for (; id_curr; id_curr = id_curr->next) { /* Note that we cannot skip indirect usages of old_id here (if requested), we still need to check it for * the user count handling... -- cgit v1.2.3