3 ms·
> there's no point in making a function that's only called in one place. There's nothing wrong with doing that if it helps make your code clearer. The compile
by throwaway81523 1y ago
> there's no point in making a function that's only called in one place.
There's nothing wrong with doing that if it helps make your code clearer. The compiler's optimizer will inline it when appropriate so there's no runtime overhead either.
- munch117 1y agoNot only that, the compiler's optimizer might actually do a better job if you split up a big function. Because the smaller functions have less register pressure.
- Neywiny 1y agoI'm not sure I agree and I think you should try some stuff out on godbolt first. The compiler can see where variables are no longer in use, whereas unless you turn on link time optimization (which is known for being messy so nobody seems to), you'll likely get a lot of unnecessary push/pop between the function calls.
- throwaway81523 1y agoDeclare the functions static and the compiler won't export the symbols and it can do more inlining.