Dan Sugalski <[EMAIL PROTECTED]> wrote:
> At 04:37 PM 8/1/00 -0400, John Tobey wrote:
> >Is foo() compiled any differently in
> >
> >     inline i_foo() { BLA; BLA; BLA; }
> >     foo() { i_foo(); }
> >
> >versus
> >
> >     foo() { BLA; BLA; BLA; }
> >
> >?
> 
> Probably. On many newer chips, the first form will probably get you a 
> function called i_foo and foo will call it, rather than actually inlining 
> the code. (Depends on how often i_foo is called) Function calls are 
> reasonably cheap, and if you have one copy of the function instead of many, 
> it may well be in the cache already, where it wouldn't be in the inlined case.
> 
> Given that some of the faster machines take a 10x speed hit getting to main 
> memory, that can make a *big* difference.

Well, I am going to assume you are wrong and the above two foo()
implementations will produce exactly the same code.  I think GCC lets
you control whether i_foo becomes a bona fide symbol by letting you
declare it `extern inline'.  In any case, I do *not* anticipate many
direct calls to i_foo() in any given translation unit.

> (FWIW, I was thinking of the difference between #define-ing a function and 
> just declaring it--I'd forgotten about the inline keyword)

Please, let's assume `inline'.

-- 
John Tobey, late nite hacker <[EMAIL PROTECTED]>
\\\                                                               ///
]]]             With enough bugs, all eyes are shallow.           [[[
///                                                               \\\

Reply via email to