Hi all,
Can someone help me understand when it is/isn't a good idea to use the "inline" keyword explicitly? Are there times when I can really make a difference using "inline"? Or is the compiler basically always smarter than me & so I should just trust it to do its thing? Currently I just use it to make code more readable. Like suppose I have confusing code to find the orientation of a face; instead of leaving it in the main body, I'll create a 'static inline' version & call out. So I'm hoping for like the readability of function calls without any of the overhead/slowdown (b/c this piece of code will run hundreds of millions of times).
If it matters, I'm coding numerical routines for C (solving the navier stokes equations); so lots of computation & lots of memory. The pieces of code I think of inlining are generally short & have small data, so it'd be cool if these functions & their variables fit into the instruction cache & registers as much as possible. Similarly it'd be good to avoid lots of useless copying variables from one place to another.
-Eric
Can someone help me understand when it is/isn't a good idea to use the "inline" keyword explicitly? Are there times when I can really make a difference using "inline"? Or is the compiler basically always smarter than me & so I should just trust it to do its thing? Currently I just use it to make code more readable. Like suppose I have confusing code to find the orientation of a face; instead of leaving it in the main body, I'll create a 'static inline' version & call out. So I'm hoping for like the readability of function calls without any of the overhead/slowdown (b/c this piece of code will run hundreds of millions of times).
If it matters, I'm coding numerical routines for C (solving the navier stokes equations); so lots of computation & lots of memory. The pieces of code I think of inlining are generally short & have small data, so it'd be cool if these functions & their variables fit into the instruction cache & registers as much as possible. Similarly it'd be good to avoid lots of useless copying variables from one place to another.
-Eric