inlining

Can I have a concise code snippet that would incur JIT inlining please?

I'm trying to produce some "Hello World" size C# code snippet that would incur JIT inlining. So far I have this: class Program { static void Main(string[] args) { Console.WriteLine( GetAssembly().FullName ); Console.ReadLine(); } static Assembly GetAssembly() { return System.Reflection.Assembly...

inlining a function

I am developing in C using gcc in Linux. I am organizing my small functions in .H and .C files in the following way // .H file extern int my_function( int val ); // .C file inline int my_function( int val ){ // my job..very short! } These functions are small so they are very good candidates to be...

Why after changing a static readonly field via reflection the output of that readonly field is old?

Why is the "someValue" variable which is readonly (but we still can change its value via reflection) output as "10", although it actually did change to 55? static class Program { static readonly int someValue = 10; static void Main(string[] args) { Console.WriteLine(someValue); // 10 typeof(Program)...

What's the difference between partial evaluation and function inlining in a functional language?

I know that: Function inlining is to replace a function call with the function definition. Partial evaluation is to evaluate the known (static) parts of a program at compile time. There is a distinction between the two in imperative languages like C, where operators are distinct from functions....

adapting a non-constexpr integral value to a non-type template parameter, and code bloat

Consider a function object F taking a constexpr size_t argument I struct F { template <size_t I> constexpr size_t operator()(size <I>) const { return I; } }; wrapped within a type size <I> , where (for brevity) template <size_t N> using size = std::integral_constant <size_t, N>; Of course, we could...

What are good heuristics for inlining functions?

Considering that you're trying solely to optimize for speed, what are good heuristics for deciding whether to inline a function or not? Obviously code size should be important, but are there any other factors typically used when (say) gcc or icc is determining whether to inline a function call? Has...