[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
On Wed, Jan 28, 2009 at 10:11:37PM -0500, Thor Lancelot Simon wrote:
> I also think that inlines in header files, for many simple purposes
> (e.g. get/set accessors for the datastructures defined in those files)
> are better than at least two common alternatives:
> 1) Macros to do the same thing. These do nothing but confuse the debugger
> and prevent type-checking.
> 2) "method" function pointers in those same datastructures, which cause a
> jump through a pointer, which can really wreck performance.
> If it's not important to keep the structure definitions and the utility
> code close together, then, sure, such functions needn't be inline. But
> in many simple cases of implementation-hiding, where, for example, an
> inline function just returns a member of a structure or union, even a
> normal function call, on almost every architecture, will at least double
> the cost.
> I generally think if it's more than about 5 lines of code, it really
> really should *not* be an inline.
I violently agree with every word. Sometimes it just makes sense to
inline bits of code. Inlines are not evil, but people can (and do)
Main Index |
Thread Index |