What technical merit is it to write this boolean return condition explicitly as if-else?

I was looking at the double

implementation from the original 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 commentary in this passage caught my attention. It says:

Jit will generate inline code with this

It looks like the developer expects the next statement to if

affect inlining and as a result selects this one line at a time return

. 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 if

this way regarding JIT optimization rules? Is it there, or could it just be a bug?

+3


source to share





All Articles