Commit: 3fb2c1e4a2f99d5de2326ab593c1d900e164e5bd
Author: Bastien Montagne
Date:   Thu Jul 7 21:18:04 2016 +0200
Branches: master
https://developer.blender.org/rB3fb2c1e4a2f99d5de2326ab593c1d900e164e5bd

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...

===================================================================

M       source/blender/blenkernel/intern/library_query.c
M       source/blender/blenkernel/intern/library_remap.c

===================================================================

diff --git a/source/blender/blenkernel/intern/library_query.c 
b/source/blender/blenkernel/intern/library_query.c
index afee80d..d068a39 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 a290c1c..491994a 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...

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to