From d566152493d583155224333576c42df92d534a18 Mon Sep 17 00:00:00 2001 From: ajaychejarla Date: Fri, 11 Oct 2019 09:23:17 -0500 Subject: [PATCH] Changed DeserializeWithLengthPrefix to yield return --- ADMPlugin/Protobuf/BaseProtobufSerializer.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/ADMPlugin/Protobuf/BaseProtobufSerializer.cs b/ADMPlugin/Protobuf/BaseProtobufSerializer.cs index 55ec869..98cfa73 100644 --- a/ADMPlugin/Protobuf/BaseProtobufSerializer.cs +++ b/ADMPlugin/Protobuf/BaseProtobufSerializer.cs @@ -105,19 +105,14 @@ public T Deserialize(string path) public IEnumerable DeserializeWithLengthPrefix(string path) where T : new() { - var itemCol = new List(); - using (var fileStream = File.OpenRead(path)) { while (!IsEndOfStream(fileStream)) { var item = new T(); - _model.DeserializeWithLengthPrefix(fileStream, item, typeof(T), PrefixStyle.Base128, 1); - itemCol.Add(item); + yield return (T)_model.DeserializeWithLengthPrefix(fileStream, item, typeof(T), PrefixStyle.Base128, 1); } } - - return itemCol; } private bool IsEndOfStream(FileStream fileStream)