mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-12-24 01:09:23 +01:00
use decompress for json saving instead
This commit is contained in:
parent
8968ec3ce0
commit
9b28ff4113
1 changed files with 2 additions and 2 deletions
|
@ -37,7 +37,7 @@ namespace MLEM.Data {
|
|||
|
||||
public static void WriteObject<T>(this NetBuffer buffer, T obj, JsonSerializer serializer) {
|
||||
using (var memory = new MemoryStream()) {
|
||||
using (var gzip = new GZipStream(memory, CompressionLevel.Fastest, true))
|
||||
using (var gzip = new DeflateStream(memory, CompressionLevel.Fastest, true))
|
||||
serializer.Serialize(new BsonDataWriter(gzip), obj, typeof(T));
|
||||
var arr = memory.ToArray();
|
||||
buffer.Write(arr.Length);
|
||||
|
@ -49,7 +49,7 @@ namespace MLEM.Data {
|
|||
var length = buffer.ReadInt32();
|
||||
var arr = buffer.ReadBytes(length);
|
||||
using (var memory = new MemoryStream(arr)) {
|
||||
using (var gzip = new GZipStream(memory, CompressionMode.Decompress, true))
|
||||
using (var gzip = new DeflateStream(memory, CompressionMode.Decompress, true))
|
||||
return serializer.Deserialize<T>(new BsonDataReader(gzip));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue