Throw helper methods #134299
Throw helper methods
#134299
|
In the past it was beneficial for high performance code to separate a throw "helper method". e.g. if(i < 0)
Throw();
...
void Throw() => throw new MyException();It was beneficial for better inlining, less code on hot paths etc. Is this still the case? Isn't the JIT going to inline these methods nowadays? |
Answered by
huoyaoyuan
Sep 20, 2026
Replies: 1 comment 1 reply
It's more important for reducing code size now. The JIT will place
JIT won't inline always-throw methods now, which is expected for optimization. It will also place the |
1 reply
Answer selected by
ladeak
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's more important for reducing code size now. The JIT will place
throwinto cold area of the method.JIT won't inline always-throw methods now, which is expected for optimization. It will also place the
callinstruction to it into cold area.