mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-26 06:28:35 +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;
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue