4 ms·
Having used some language with awful compilers, compiler optimisations let me write cleaner code. In languages with bad optimisers I have to worry about separa
by CJefferson 9y ago
Having used some language with awful compilers, compiler optimisations let me write cleaner code.
In languages with bad optimisers I have to worry about separating code in a hot loop out into a function -- the cost of a function call is too high. This one in particular I find can lead to some horrible code, as functions grow larger and larger and lots of cutting+pasting happens to avoid function call costs.
On a smaller note, making sure I cache the values of function calls which won't change -- when instead I could trust the compiler to know the value won't change and the the caching itself.
- gruez 9y agoThere isnt some forcelinline attribute in gcc?
- Paul_S 9y agoYeah, #define.
- JoachimSchipper 9y agoYour parent is probably not talking about gcc, or even about C; gcc does indeed have __attribute__((always_inline)).
- CJefferson 9y agoThere is, but in practice just normal inline, or even trusting the compiler to decide what to inline itself, are just fine. The problem comes when you are using other languages (scripting ones like Python come to mind) where inlining is but a dream (ignoring systems like PyPy).