There this function from std.Io that I can’t stop thinking about:
the function Reader.fill is split between Reader.fill that contains the early return case where nothing needs to be done, and Reader.fillUnbeffered where the actual prefill happen. This allows the early return branch to be inlined at the call site, and save the cost of a functon call in that case.
So my question is should I program like this?
While searching the topic I learned that LLVM does have a partial inlining pass, that is aimed at automaticallysolving this specific issue, but it’s not enabled by default.
Has anyone here tried that pass?
It seems like it would be great in Zig, eg I often have asserts at the top of my function that arguably would be better located on the caller side.