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:
parent
0824ba1098
commit
14bce69521
1 changed files with 4 additions and 4 deletions
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue