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
c # .net inline jit


source to share


No one has answered this question yet

See similar questions:

2
JIT ditches inline tiny methods

or similar:

358
If my interface needs to return Task, what is the best way to implement it without an operation?
277
What is the difference between bool and Boolean types in C #
217
What LINQ Returns When Results Are Empty
215
What actually happens in try {return x; } finally {x = null; } expression?
177
What is the purpose of "come back wait" in C #?
151
Which method in the String class only returns the first N characters?
23
otherwise or return?
fourteen
unexplained 10% + performance improvement from just adding a method argument (thinner jit code)
ten
Using C # Types to Express Units
3
Nesting private and secured virtual function calls



All Articles
Loading...
X
Show
Funny
Dev
Pics