Excessive Inlining

I

Ian Collins

James said:
I'm refering to the use of the "inline" keyword, of course.
You're right that some modern compilers will inline without it,
across compilation units, and according to the profiler data.
I see. In practice, I have found the "inline" keyword to be of little
use, the compiler is free to ignore it and in most case one has to jump
through hoops to get the compiler to inline a function that it doesn't
consider appropriate. So I never use it.
It does.

As with any rule, it can be violated when there are overriding
reasons to do so. But these are rare in application code, and I
can't remember every having seen a template definition in
application code in production software.
I guess that's a point of style, or I don't write what you consider
"Application" code. I invariably break into templates before too long.
Just about everything I have ever written contains at least some
components that are generic.

If you exclude templates, do you also exclude the standard library?
Still broken!
 
D

Dave Rahardja

I'm refering to the use of the "inline" keyword, of course.
You're right that some modern compilers will inline without it,
across compilation units, and according to the profiler data.

Some compilers I've worked with use the "inline" keyword to bias the "inlining
score" that is used to determine if a function is going to be inlined.

Most of the compilers I've worked with require the code to be visible in the
compilation unit for the inlining to take place (i.e. no link-time inlining).
In such cases, the "inline" keyword is required to prevent the "multiple
definition" error from arising.

It does.

As with any rule, it can be violated when there are overriding
reasons to do so. But these are rare in application code, and I
can't remember every having seen a template definition in
application code in production software.

In practice, this isn't that restricting. "Application"
generally means dealing with known types anyway, unless you need
dynamic dispatch. Templates tend to be restricted to lower
level, very stable libraries. Libraries that are considered so
fundamental that 1) upgrading to a more recent version is
considered a major undertaking, much like moving to a new
version of the compiler and 2) if you do it, you recompile
everything and run the entire regression test suite again,
before going further.

I disagree with your assessment, but I suppose it depends on your application
domain. I find that almost all of the "application" code I've worked on use
templates at the application level.

Do you mean that you don't _use_ templates at the application level (not even
using their definitions from a library), or that you merely don't _define_
application-level templated entities?

-dr
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top