在一行上定义多个变量,这是否为构建过程提供了任何优化? [英] Defining multiple variables on one line, does this offer any optimization for the build process?
问题描述
在一行上定义多个变量是否为构建过程提供了某种形式的优化,还是只是一种编码风格的选择?
Does defining multiple variables on one line offer some form of optimization for the build process or is it simply a choice of coding style?
例如: / p>
For example would this:
void foo()
{
int a, b, c, d;
..... // do something with a,b,c and d
}
提供此优化:
void bar()
{
int a;
int b;
int c;
int d;
..... // do something with a,b,c and d
}
推荐答案
可能是的。对于编译器,较小的输入文件读取速度更快。但它将依赖于编译器的实现。如果你有兴趣以编译器独立的方式减少构建时间,还有很多其他的优化可以做。 大型C ++软件设计作者John Lakos是一本很好读的书。
Possibly, yes. Smaller input files are faster to read for the compiler. But it would depend a lot on the implementation of the compiler. If you are interested in reducing build times in a compiler independent manner, there are a lot of other optimisations which can be done. Large-Scale C++ Software Design by John Lakos is a very good book to read for this.
这篇关于在一行上定义多个变量,这是否为构建过程提供了任何优化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!