diff options
| author | Anthony Lavado <anthony@lavado.ca> | 2020-08-13 13:01:43 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-13 13:01:43 -0400 |
| commit | 5480674c4fcf279bab640f24131d188a6a089eb4 (patch) | |
| tree | 95f2b9f47176334f74f774563a35aa68275cc9dd /Emby.Server.Implementations/Serialization | |
| parent | 32d465742989520b8cd9ecdad759ed9cfc128a54 (diff) | |
| parent | 593dbcabffd1a0c09af64f3a19ed46c97d626559 (diff) | |
Merge pull request #3838 from Bond-009/memorystream
MemoryStream optimizations
Diffstat (limited to 'Emby.Server.Implementations/Serialization')
| -rw-r--r-- | Emby.Server.Implementations/Serialization/MyXmlSerializer.cs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Emby.Server.Implementations/Serialization/MyXmlSerializer.cs b/Emby.Server.Implementations/Serialization/MyXmlSerializer.cs index 296822981..27024e4e1 100644 --- a/Emby.Server.Implementations/Serialization/MyXmlSerializer.cs +++ b/Emby.Server.Implementations/Serialization/MyXmlSerializer.cs @@ -3,6 +3,7 @@ using System.Collections.Concurrent; using System.IO; using System.Xml; using System.Xml.Serialization; +using MediaBrowser.Model.IO; using MediaBrowser.Model.Serialization; namespace Emby.Server.Implementations.Serialization @@ -53,10 +54,11 @@ namespace Emby.Server.Implementations.Serialization /// <param name="stream">The stream.</param> public void SerializeToStream(object obj, Stream stream) { - using (var writer = new XmlTextWriter(stream, null)) + using (var writer = new StreamWriter(stream, null, IODefaults.StreamWriterBufferSize, true)) + using (var textWriter = new XmlTextWriter(writer)) { - writer.Formatting = Formatting.Indented; - SerializeToWriter(obj, writer); + textWriter.Formatting = Formatting.Indented; + SerializeToWriter(obj, textWriter); } } @@ -95,7 +97,7 @@ namespace Emby.Server.Implementations.Serialization /// <returns>System.Object.</returns> public object DeserializeFromBytes(Type type, byte[] buffer) { - using (var stream = new MemoryStream(buffer)) + using (var stream = new MemoryStream(buffer, 0, buffer.Length, false, true)) { return DeserializeFromStream(type, stream); } |
