Hi, It seems that we have some much-included header files including <algorithm> just to get std::min and std::max.
That seems like an extreme case of low ratio between lines of code included (9,290 on my system, see Appendix below) and lines of code actually used (say 6 with whitespace). I ran into this issue while trying to minimize nsCoord.h ( https://bugzilla.mozilla.org/show_bug.cgi?id=913868 ) and in my patch, I resorted to defining my own min/max functions in a nsCoords_details namespace. This prompted comments on that bug suggesting that it might be better to have that in MFBT. But that, in turn, sounds like overturning our recent decision to switch to std::min / std::max, which I feel is material for this mailing list. It is also conceivable to keep saying that we should use std::min / std::max *except* in headers that don't otherwise include <algorithm>, where it may be more reasonable to use the cheap-to-#include variant instead. What do you think? Benoit === Appendix: how big and long to compile is <algorithm> ? === On my Ubuntu 12.04 64bit system, with GCC 4.6.3, including <algorithm> means recursively including 9,290 lines of code: $ echo '#include<algorithm>' > a.cpp && g++ -save-temps -c a.cpp && wc -l a.ii 9290 a.ii On may wonder what this implies in terms of compilation times; here is a naive answer. I'm timing 10 successive compilations of a file that just includes <iostream>, and then I do the same with a file that also includes <algorithm>. $ echo '#include<iostream>' > a.cpp && time (g++ -c a.cpp && g++ -c a.cpp && g++ -c a.cpp && g++ -c a.cpp && g++ -c a.cpp && g++ -c a.cpp && g++ -c a.cpp && g++ -c a.cpp && g++ -c a.cpp && g++ -c a.cpp) real 0m1.391s user 0m1.108s sys 0m0.212s echo '#include<algorithm>' > a.cpp && echo '#include<iostream>' >> a.cpp && time (g++ -c a.cpp && g++ -c a.cpp && g++ -c a.cpp && g++ -c a.cpp && g++ -c a.cpp && g++ -c a.cpp && g++ -c a.cpp && g++ -c a.cpp && g++ -c a.cpp && g++ -c a.cpp) real 0m1.617s user 0m1.324s sys 0m0.244s (I actually repeated this many times and kept the best result for each; my hardware is a Thinkpad W520 with a 2.5GHz, 8M cache Core i7). So we see that adding the #include<algorithm> made each compilation 23 ms longer in average (226 ms for 10 compilations). _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform