1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-29 15:58:33 +01:00

this has been bugging me for a while

This commit is contained in:
Ellpeck 2020-01-27 22:31:09 +01:00
parent 0824ba1098
commit 14bce69521

View file

@ -42,8 +42,8 @@ namespace MLEM.Data {
return; return;
} }
using (var memory = new MemoryStream()) { using (var memory = new MemoryStream()) {
using (var gzip = new DeflateStream(memory, CompressionLevel.Fastest, true)) using (var stream = new DeflateStream(memory, CompressionLevel.Fastest, true))
serializer.Serialize(new BsonDataWriter(gzip), obj, typeof(T)); serializer.Serialize(new BsonDataWriter(stream), obj, typeof(T));
var arr = memory.ToArray(); var arr = memory.ToArray();
buffer.Write(arr.Length); buffer.Write(arr.Length);
buffer.Write(arr); buffer.Write(arr);
@ -56,8 +56,8 @@ namespace MLEM.Data {
return default; return default;
var arr = buffer.ReadBytes(length); var arr = buffer.ReadBytes(length);
using (var memory = new MemoryStream(arr)) { using (var memory = new MemoryStream(arr)) {
using (var gzip = new DeflateStream(memory, CompressionMode.Decompress, true)) using (var stream = new DeflateStream(memory, CompressionMode.Decompress, true))
return serializer.Deserialize<T>(new BsonDataReader(gzip)); return serializer.Deserialize<T>(new BsonDataReader(stream));
} }
} }