bib*_*sey 1 c++ boolean function
说,我有一个如下所示的功能
void caller()
{
int flag = _getFlagFromConfig();
//this is a flag, which according to the implementation
//is supposed to have only two values, 0 and 1 (as of now)
callee_1(flag);
callee_2(1 == flag);
}
void callee_1(int flag)
{
if (1 == flag)
{
//do operation X
}
}
void callee_2(bool flag)
{
if (flag)
{
//do operation X
}
}
Run Code Online (Sandbox Code Playgroud)
哪个被调用函数将是更好的实现?
我已经完成了这个链接,并且我非常确信在一个if条件下将bool用于比较没有太大的性能影响.但在我的情况下,我将标志作为整数.在这种情况下,第二个被叫者是否值得去?