Hacker News new | ask | show | jobs
by anon-3988 4 days ago
I don't understand why Result type is necessarily slower. Result that simply bubbles up is basically an exception, no?
1 comments

You need instructions to check the result type, and a bit somewhere to store whether it's valid. Most exceptions only add extra instructions during throws/unwinding. There may or may not be an overall reduction in code size, depending on how many checks you have vs table entries.
In theory, a compiler can figure out that you don't need that in some cases.