1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-22 20:58:34 +01:00
This commit is contained in:
Ellpeck 2019-12-20 23:35:38 +01:00
parent 9781722ae4
commit a53179e2d8

View file

@ -37,8 +37,10 @@ namespace MLEM.Data {
}
public static void WriteObject<T>(this NetBuffer buffer, T obj, JsonSerializer serializer) {
if (EqualityComparer<T>.Default.Equals(obj, default))
if (EqualityComparer<T>.Default.Equals(obj, default)) {
buffer.Write(0);
return;
}
using (var memory = new MemoryStream()) {
using (var gzip = new DeflateStream(memory, CompressionLevel.Fastest, true))
serializer.Serialize(new BsonDataWriter(gzip), obj, typeof(T));