This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: selective function call


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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]