[Bf-committers] Simplifying node tree do_versions

Lukas Tönne lukas.toenne at gmail.com
Fri Feb 8 10:38:58 CET 2013

I propose to introduce a C macro for use in readfile.c to clean up the
frequent node tree do_versions mess. Currently whenever we need to
iterate over all node trees in the library data we have to either make
a number of repetitive bloated loops and/or use callbacks outside the
actual do_versions function. Here's an example of one of my own fixes:


As you can see the loops in do_versions and the actual fix in the
callback are spaced far apart and to figure out what is going on you
have to jump around in this monster file quite a lot. Furthermore
since we have node trees in 6 different ID data blocks currently it
requires looping over all these blocks to iterate all potential node

This macro would help make the code localized to just a few lines like
most of the other do_versions code and keep things much more readable:


The macro automatically loops over all existing node trees with a
single inner code block, so you don't have to repeat the same code
over and over. If necessary it can be filtered easily by checking the
node tree type. A minor overhead for looping over unused node trees
would be added, but that should be nowhere near significant.

Using it for the example above boils it down to:


More information about the Bf-committers mailing list