I was looking at the double
implementation from Reference Source and saw the following function definition:
[Pure]
[System.Runtime.Versioning.NonVersionable]
public static bool IsPositiveInfinity(double d) {
//Jit will generate inlineable code with this
if (d == double.PositiveInfinity)
{
return true;
}
else
{
return false;
}
}
The comment in that excerpt caught my attention. It says:
Jit will generate inlineable code with this
It seems to indicate that the developer expects the following if
statement to influence inlining, and as a result is choosing that over a single return
line. I understand the concept of JIT inlining (at least, I thought I did) but I don't see how the "if" construct relates to such an operation.
What is the advantage of writing the if
in this way in regard to JIT's optimization rules? Is there one, or might this simply be a mistake?