diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-01-16 19:14:57 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-01-16 19:14:57 +0300 |
commit | 9d1ae07d4fe347c8ddd37c9c1b2e35d31c0690e1 (patch) | |
tree | 60982ab0dc3623db078b9683430c0c1ad69ed050 /source/blender/blenloader | |
parent | b55111f8f6575490b1db91c4a8a314607acf76a7 (diff) |
Cleanup: Avoid ifdefs in multiple places
Define a helper macro. Makes code read easier.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index bc51f0fe96b..40b53d4c684 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -220,6 +220,15 @@ /* Use GHash for restoring pointers by name */ #define USE_GHASH_RESTORE_POINTER +/* Define this to have verbose debug prints. */ +#define USE_DEBUG_PRINT + +#ifdef USE_DEBUG_PRINT +# define DEBUG_PRINTF(...) printf(__VA_ARGS__) +#else +# define DEBUG_PRINTF(...) +#endif + /***/ typedef struct OldNew { @@ -8124,22 +8133,16 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const short if (fd->memfile && ELEM(bhead->code, ID_LI, ID_ID)) { const char *idname = bhead_id_name(fd, bhead); -#ifdef PRINT_DEBUG - printf("Checking %s...\n", idname); -#endif + DEBUG_PRINTF("Checking %s...\n", idname); if (bhead->code == ID_LI) { Main *libmain = fd->old_mainlist->first; /* Skip oldmain itself... */ for (libmain = libmain->next; libmain; libmain = libmain->next) { -#ifdef PRINT_DEBUG - printf("... against %s: ", libmain->curlib ? libmain->curlib->id.name : "<NULL>"); -#endif + DEBUG_PRINTF("... against %s: ", libmain->curlib ? libmain->curlib->id.name : "<NULL>"); if (libmain->curlib && STREQ(idname, libmain->curlib->id.name)) { Main *oldmain = fd->old_mainlist->first; -#ifdef PRINT_DEBUG - printf("FOUND!\n"); -#endif + DEBUG_PRINTF("FOUND!\n"); /* In case of a library, we need to re-add its main to fd->mainlist, because if we have later * a missing ID_ID, we need to get the correct lib it is linked to! * Order is crucial, we cannot bulk-add it in BLO_read_from_memfile() like it used to be... */ @@ -8153,19 +8156,13 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const short } return blo_nextbhead(fd, bhead); } -#ifdef PRINT_DEBUG - printf("nothing...\n"); -#endif + DEBUG_PRINTF("nothing...\n"); } } else { -#ifdef PRINT_DEBUG - printf("... in %s (%s): ", main->curlib ? main->curlib->id.name : "<NULL>", main->curlib ? main->curlib->name : "<NULL>"); -#endif + DEBUG_PRINTF("... in %s (%s): ", main->curlib ? main->curlib->id.name : "<NULL>", main->curlib ? main->curlib->name : "<NULL>"); if ((id = BKE_libblock_find_name_ex(main, GS(idname), idname + 2))) { -#ifdef PRINT_DEBUG - printf("FOUND!\n"); -#endif + DEBUG_PRINTF("FOUND!\n"); /* Even though we found our linked ID, there is no guarantee its address is still the same... */ if (id != bhead->old) { oldnewmap_insert(fd->libmap, bhead->old, id, GS(id->name)); @@ -8177,9 +8174,7 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const short } return blo_nextbhead(fd, bhead); } -#ifdef PRINT_DEBUG - printf("nothing...\n"); -#endif + DEBUG_PRINTF("nothing...\n"); } } |