From 3e61fd10d693a45c520b7436097919bc68eface0 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 26 Oct 2026 09:53:21 -0500 Subject: cache default serializer options --- src/slskd/Common/CommonExtensions.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/slskd/Common/CommonExtensions.cs b/src/slskd/Common/CommonExtensions.cs index 95721163..47e4aee1 100644 --- a/src/slskd/Common/CommonExtensions.cs +++ b/src/slskd/Common/CommonExtensions.cs @@ -53,6 +53,8 @@ namespace slskd /// public static class CommonExtensions { + private static readonly JsonSerializerOptions DefaultJsonSerializerOptions = GetJsonSerializerOptions(); + /// /// Times this Task out after the specified TimeSpan. /// @@ -358,7 +360,7 @@ namespace slskd /// /// The object to serialize. /// A string containing the serialized object. - public static string ToJson(this object obj) => JsonSerializer.Serialize(obj, GetJsonSerializerOptions()); + public static string ToJson(this object obj) => JsonSerializer.Serialize(obj, DefaultJsonSerializerOptions); /// /// Serializes this object to yaml. @@ -481,7 +483,7 @@ namespace slskd /// The type to which to deserialize the string. /// The string to deserialize. /// The new object deserialized from the string. - public static T FromJson(this string str) => JsonSerializer.Deserialize(str, GetJsonSerializerOptions()); + public static T FromJson(this string str) => JsonSerializer.Deserialize(str, DefaultJsonSerializerOptions); /// /// Applies the standard json serializer options to the specified instance. -- cgit v1.2.3