Questions tagged [inlining]

Inlining is a compiler optimization which eliminates function calls by replacing them with the function's code, thus executing it inline. Use this tag for question about this kind of optimization, combined with the appropriate language tag and, where applicable, compiler tag.

Inlining a function is the process of replacing a call to a function with the implementation of the function. In contrast, in various versions of the C and C++ programming languages, an inline function is a function whose definition (function body) can be exposed to multiple translation units without link time errors. This eases the ability for the compiler to "inline expand" the code at the locations where it is called, rather than generating code to call the function in the one place it is defined. Compilers are not obligated to respect the implied request by the inline keyword to "inline expand" the code at the point of call.

145 questions
62
votes
3 answers

Are functors actually faster than pointers to functions?

According to Scott Meyers, one area where C++ shines over C is that function objects are faster than function pointers. He says this is because function objects are inlined, which increases speed. I have two questions about this: How can we verify…
user7140484
  • 920
  • 6
  • 14
41
votes
5 answers

When is a method eligible to be inlined by the CLR?

I've observed a lot of "stack-introspective" code in applications, which often implicitly rely on their containing methods not being inlined for their correctness. Such methods commonly involve calls…
Ani
  • 111,048
  • 26
  • 262
  • 307
41
votes
10 answers

What is inlining?

I am referring to this discussion. I have never written any code in C or in C++ . I do not have any CS background. However I have been working as Java developer for 5 years and now I have decided to learn more about CS and do some catching up.
Roger
  • 3,919
  • 7
  • 30
  • 37
40
votes
8 answers

Inlining in Java

In C++ I can declare a method "inline" and the compiler is likely to inline it. As far as I understand there is no such keyword in Java. Inlining is done if the JVM decides to do so? Can I influence this decision somehow?
CL23
  • 766
  • 2
  • 7
  • 12
36
votes
2 answers

Preventing JIT inlining on a method

I've got sort of a unique situation. I've been working on an open source library for sending email. In this library, I need a reliable way to get the calling method. I've done this with a StackTrace by analyzing the StackFrame objects inside it. …
Scott Arrington
  • 12,325
  • 3
  • 42
  • 54
31
votes
2 answers

Why does compiler inlining produce slower code than manual inlining?

Background The following critical loop of a piece of numerical software, written in C++, basically compares two objects by one of their members: for(int j=n;--j>0;) asd[j%16]=a.e
Johannes Gerer
  • 25,508
  • 5
  • 29
  • 35
29
votes
8 answers

Inlining CSS in C#

I need to inline css from a stylesheet in c#. Like how this works. http://www.mailchimp.com/labs/inlinecss.php The css is simple, just classes, no fancy selectors. I was contemplating using a regex (?(?[^{}]+){(?