Re: selective function call

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/29/05, Ingo Krabbe  wrote:
> I assume your problem actual performance problem is the generation of
> arguments (ackerman(5,5)), which should only be executed if the
>arguments are really needed.
  I agree that the problem is not in parameter passing, but in evaluation
of ackerman(5,5).
  Yet if you really sure that parameter passing slows you down,
you can do some c++ trick (not recommended, however):

inline void tLogger::print("args") {
   if ("enabled"){
        really_print("args of 'print' passed thru");
   }
}

This can work, hoping that compiler will inline the outer "print",
and a stack frame will not be created,
untill the resolution of "enabled".

> The great advantage of these simple if decisions is that you will
> understand
> your code one year later  and other might want to read it too and will be
> able to understand it.

Here I believe that the code without "ifs" can be more readable.

Regards,
 Dima.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux