Skip to content

Add aggressive method inlining attribute to equals on JsonNumber, JsonString and JsonBoolean  #30545

@kasiabulat

Description

@kasiabulat

Check if the JsonNumber (JsonString and JsonBoolean) implementation of == operator:

public static bool operator ==(JsonNumber left, JsonNumber right)
{
    // Test "right" first to allow branch elimination when inlined for null checks (== null)
    // so it can become a simple test
    if (right is null)
    {
        // return true/false not the test result https://github.com/dotnet/coreclr/issues/914
        return (left is null) ? true : false;
    }

    return right.Equals(left);
}

remains simple or gets more complex and if requires the [MethodImpl(MethodImplOptions.AggressiveInlining)] attribute and how adding it will affect performance.

_Originally posted by @ahsonkhan in dotnet/corefx#40107 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions