eg.

// global flag
bool gLog;


void Log1(char* format, ...)
{
if(gLog)
{
va_list args;
va_start(args, pzFormat);
vprintf(format, args);
va_end(args);
}

}


void Log2(char* format, ...)
{

va_list args;
va_start(args, pzFormat);
vprintf(format, args);
va_end(args);


}
void main()
{
// scenario (1)
Log1("helloworld %d", 1);

// scenario (2)
if(gLog)
Log2("helloworld %d", 2);

}


what log function is more efficient (1) or (2) it can be an efficiency
of even a single instruction 

my point is
in (1)
you call Log1 with vargs causing Log1 to get vargs at runtime (there
will be additional code to go thru). As i 'think' compiler inserts
code to collect the vargs to return them to the function, no matter we
use va_start etc.

in (2)
only if gLog is set it will have to go thru that code


indika

Reply via email to