diff options
| author | Bond_009 <bond.009@outlook.com> | 2022-02-21 14:15:09 +0100 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2022-02-21 14:15:09 +0100 |
| commit | f50a250cd9fac47bcbd9a05e99c8ffe4d294e320 (patch) | |
| tree | b205dccb83ad385b0ac338b00680aa4f97fe9b97 /src | |
| parent | bbac59c6d627ef3ef67e26b10d6571cd9a260466 (diff) | |
Optimize Guid comparisons
* Use Guid.Equals(Guid) instead of the == override
* Ban the usage of Guid.Equals(Object) to prevent accidental boxing
* Compare to default(Guid) instead of Guid.Empty
Diffstat (limited to 'src')
| -rw-r--r-- | src/Jellyfin.Extensions/Json/Converters/JsonNullableGuidConverter.cs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/Jellyfin.Extensions/Json/Converters/JsonNullableGuidConverter.cs b/src/Jellyfin.Extensions/Json/Converters/JsonNullableGuidConverter.cs index b477bcb66..656e3c3da 100644 --- a/src/Jellyfin.Extensions/Json/Converters/JsonNullableGuidConverter.cs +++ b/src/Jellyfin.Extensions/Json/Converters/JsonNullableGuidConverter.cs @@ -16,14 +16,15 @@ namespace Jellyfin.Extensions.Json.Converters /// <inheritdoc /> public override void Write(Utf8JsonWriter writer, Guid? value, JsonSerializerOptions options) { - if (value == Guid.Empty) + // null got handled higher up the call stack + var val = value!.Value; + if (val.Equals(default)) { writer.WriteNullValue(); } else { - // null got handled higher up the call stack - JsonGuidConverter.WriteInternal(writer, value!.Value); + JsonGuidConverter.WriteInternal(writer, val); } } } |
