Re: selective function call

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

 



Am Dienstag, 29. November 2005 12:47 schrieb Dima Sorkin:
> 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.

Actually every programmer will know what if means.  If you read LOG(X,Y,Z) you 
won't know what this means, until you lookup LOG(X,Y,Z).

Of course LOG() is quite short as

int main(int argc, char**argv) { return run(argc,argv); }

well quite readable but you won't know what happens.

Logging code blocks should be like paragraphs anyway.

BYE INGO

[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