[Bf-blender-cvs] [5d45ffc] master: readfile: minor optimization, no need to count flags
Campbell Barton
noreply at git.blender.org
Mon Jun 6 11:03:57 CEST 2016
Commit: 5d45ffc755e3c7961cadd007e7440ec1fe8b6dbe
Author: Campbell Barton
Date: Mon Jun 6 19:03:09 2016 +1000
Branches: master
https://developer.blender.org/rB5d45ffc755e3c7961cadd007e7440ec1fe8b6dbe
readfile: minor optimization, no need to count flags
in this case we only need to check if any id's need to be read.
===================================================================
M source/blender/blenloader/intern/readfile.c
===================================================================
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index a6fc2a8..df36def 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -9990,21 +9990,22 @@ void *BLO_library_read_struct(FileData *fd, BHead *bh, const char *blockname)
/* ************* READ LIBRARY ************** */
-static int mainvar_count_libread_blocks(Main *mainvar)
+static int mainvar_id_tag_any_check(Main *mainvar, const short tag)
{
ListBase *lbarray[MAX_LIBARRAY];
- int a, tot = 0;
+ int a;
a = set_listbasepointers(mainvar, lbarray);
while (a--) {
ID *id;
for (id = lbarray[a]->first; id; id = id->next) {
- if (id->tag & LIB_TAG_READ)
- tot++;
+ if (id->tag & tag) {
+ return true;
+ }
}
}
- return tot;
+ return false;
}
static void read_libraries(FileData *basefd, ListBase *mainlist)
@@ -10024,10 +10025,9 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
/* test 1: read libdata */
mainptr= mainl->next;
while (mainptr) {
- int tot = mainvar_count_libread_blocks(mainptr);
-
- // printf("found LIB_TAG_READ %s\n", mainptr->curlib->name);
- if (tot) {
+ if (mainvar_id_tag_any_check(mainptr, LIB_TAG_READ)) {
+ // printf("found LIB_TAG_READ %s\n", mainptr->curlib->name);
+
FileData *fd = mainptr->curlib->filedata;
if (fd == NULL) {
More information about the Bf-blender-cvs
mailing list