Unity Build Module Question


#1

The principle behind a UB is quite simple. It’s all about reducing…

… the number of times a file is opened.
… the number of files that are opened.

I was just going over this article again, http://buffered.io/posts/the-magic-of-unity-builds/ , and wondered why you eventually removed the guards around the header include of every module's series of files? If the quote stands true, wouldn't keeping the guards around the includes additionally decrease compile time?

Since no project is perfect; "JuceHeader.h" will likely be included multiple times. "JuceHeader.h" includes all the headers of the project's modules, and the files related to the modules will get included again, too.

I'm not sure how much of a difference doing so can make in small scale projects (e.g.: JUCE's Demo), but could perhaps be worthwhile for large scale ones.

I don't have the means of doing an A/B test right now - but am curious!


#2

JuceHeader.h itself does have a guard around it, so including it multiple times is fine! Within it, I could be confident that many files aren't included more than once, so a lot of their guards aren't needed. TBH I've only really removed guards for reasons of tidiness when reading the code, since any performance improvement would be imperceptible.