News for hackers. Stuff that matters.
Re:John Carmack on Inlined Code (2014) by m0zg on Tuesday January 22, 2019 @04:13AM (#18967069)
But then they won't be 10 lines or less anymore.
Re:John Carmack on Inlined Code (2014) by icebraining on Tuesday January 22, 2019 @04:41AM (#18967166)
Yeah, but if you have A() calls B() calls C(), and they're all a few lines long, how do you decide which ones to inline? If you just do it as you're writing, don't you end up missing inlining opportunities further ahead just because you've already inlined before, and therefore the resulting function is too big to be further inlined?
Re:John Carmack on Inlined Code (2014) by m0zg on Tuesday January 22, 2019 @05:12AM (#18967268)
>> how do you decide which ones to inline

Use whichever setup maximizes readability. Lift code out into functions if it's a logical, reasonably self contained block used 3 or more times. Use your best judgment, in other words. If you require me to jump around the file (or worse, files, plural) to read your code, make sure there's a good reason for all this cognitive overhead.