1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-22 12: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;
}
using (var memory = new MemoryStream()) {
using (var gzip = new DeflateStream(memory, CompressionLevel.Fastest, true))
serializer.Serialize(new BsonDataWriter(gzip), obj, typeof(T));
using (var stream = new DeflateStream(memory, CompressionLevel.Fastest, true))
serializer.Serialize(new BsonDataWriter(stream), obj, typeof(T));
var arr = memory.ToArray();
buffer.Write(arr.Length);
buffer.Write(arr);
@ -56,8 +56,8 @@ namespace MLEM.Data {
return default;
var arr = buffer.ReadBytes(length);
using (var memory = new MemoryStream(arr)) {
using (var gzip = new DeflateStream(memory, CompressionMode.Decompress, true))
return serializer.Deserialize<T>(new BsonDataReader(gzip));
using (var stream = new DeflateStream(memory, CompressionMode.Decompress, true))
return serializer.Deserialize<T>(new BsonDataReader(stream));
}
}