Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

andrewjsaid
Copy link
Contributor

Following #104048 (comment)

JsonElement.ValueKind actually does quite a few operations as described below. This PR is a small change so that it's only called once.

public JsonValueKind ValueKind => TokenType.ToValueKind();`
private JsonTokenType TokenType => _parent?.GetJsonTokenType(_idx) ?? JsonTokenType.None
internal JsonTokenType GetJsonTokenType(int index)
{
    CheckNotDisposed();

    return _parsedData.GetJsonTokenType(index);
}
internal JsonTokenType GetJsonTokenType(int index)
{
    AssertValidIndex(index);
    uint union = MemoryMarshal.Read<uint>(_data.AsSpan(index + NumberOfRowsOffset));

    return (JsonTokenType)(union >> 28);
}

cc @eiriktsarpalis

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jun 27, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis
See info in area-owners.md if you want to be subscribed.

Copy link
Member

@eiriktsarpalis eiriktsarpalis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@eiriktsarpalis eiriktsarpalis merged commit daadf8e into dotnet:main Jul 1, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Text.Json community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants