Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Improve perf of JsonValue.CreateFromElement by calling ValueKind once#104108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Changes from2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
Expand DownExpand Up@@ -181,18 +180,22 @@ internal static JsonValue CreateFromTypeInfo<T>(T value, JsonTypeInfo<T> jsonTyp

internal static JsonValue? CreateFromElement(ref readonly JsonElement element, JsonNodeOptions? options = null)
{
if (element.ValueKind is JsonValueKind.Null)
switch (element.ValueKind)
{
return null;
}
case JsonValueKind.Null:
return null;

// Force usage of JsonArray and JsonObject instead of supporting those in an JsonValue.
if (element.ValueKind is JsonValueKind.Object or JsonValueKind.Array)
{
ThrowHelper.ThrowInvalidOperationException_NodeElementCannotBeObjectOrArray();
}
case JsonValueKind.Object:
case JsonValueKind.Array:
// Force usage of JsonArray and JsonObject instead of supporting those in an JsonValue.
ThrowHelper.ThrowInvalidOperationException_NodeElementCannotBeObjectOrArray();

// The above method will throw, but the compiler doesn't know that.
return default;

return new JsonValueOfElement(element, options);
default:
return new JsonValueOfElement(element, options);
}
}
}
}

[8]ページ先頭

©2009-2025 Movatter.jp