4 ms·
> If it calls 10 functions, then the equivalent "inlined" function written under my rule is at most 100 lines long Only if those 10 functions weren't already i
by icebraining 8y ago
> If it calls 10 functions, then the equivalent "inlined" function written under my rule is at most 100 lines long
Only if those 10 functions weren't already inlined themselves.
- m0zg 8y agoBut then they won't be 10 lines or less anymore.
- icebraining 8y agoYeah, 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?
- m0zg 8y ago>> 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.