mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-23 09:14:45 +03:00
JsonSerializer deserialize from bytes where possible
This is faster and uses way less memory ``` BenchmarkDotNet=v0.12.1, OS=fedora 32 Intel Core i7-6700HQ CPU 2.60GHz (Skylake), 1 CPU, 8 logical and 4 physical cores .NET Core SDK=5.0.100 [Host] : .NET Core 5.0.0 (CoreCLR 5.0.20.51904, CoreFX 5.0.20.51904), X64 RyuJIT DefaultJob : .NET Core 5.0.0 (CoreCLR 5.0.20.51904, CoreFX 5.0.20.51904), X64 RyuJIT | Method | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated | |------- |---------:|--------:|--------:|--------:|------:|------:|----------:| | Bytes | 158.4 us | 2.56 us | 2.14 us | 16.8457 | - | - | 52.08 KB | | String | 172.8 us | 0.78 us | 0.70 us | 41.5039 | - | - | 127.82 KB | | Custom | 155.5 us | 2.95 us | 2.76 us | 10.0098 | - | - | 31.27 KB | ```
This commit is contained in:
@@ -514,12 +514,10 @@ namespace Emby.Server.Implementations.Plugins
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = File.ReadAllText(metafile, Encoding.UTF8);
|
||||
var data = File.ReadAllBytes(metafile);
|
||||
manifest = JsonSerializer.Deserialize<PluginManifest>(data, _jsonOptions);
|
||||
}
|
||||
#pragma warning disable CA1031 // Do not catch general exception types
|
||||
catch (Exception ex)
|
||||
#pragma warning restore CA1031 // Do not catch general exception types
|
||||
catch (JsonException ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error deserializing {Path}.", dir);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user