From 6f1baf8b90cf78233b52614761b4c0b59783a601 Mon Sep 17 00:00:00 2001 From: CyrusNajmabadi Date: Tue, 9 May 2017 15:22:39 -0700 Subject: [PATCH] Write out less data for objects. --- src/Compilers/Core/Portable/Serialization/ObjectReader.cs | 3 +-- src/Compilers/Core/Portable/Serialization/ObjectWriter.cs | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Compilers/Core/Portable/Serialization/ObjectReader.cs b/src/Compilers/Core/Portable/Serialization/ObjectReader.cs index 50757add9b0..4e150a112bd 100644 --- a/src/Compilers/Core/Portable/Serialization/ObjectReader.cs +++ b/src/Compilers/Core/Portable/Serialization/ObjectReader.cs @@ -32,7 +32,7 @@ internal sealed partial class ObjectReader : IDisposable /// this version, just change VersionByte2. /// internal const byte VersionByte1 = 0b10101010; - internal const byte VersionByte2 = 0b00000111; + internal const byte VersionByte2 = 0b00001000; private readonly BinaryReader _reader; private readonly CancellationToken _cancellationToken; @@ -580,7 +580,6 @@ private object ReadObject() { var id = _objectReferenceMap.GetNextReferenceId(); - _reader.ReadByte(); var typeReader = _binderSnapshot.GetTypeReaderFromId(this.ReadInt32()); // recursive: read and construct instance immediately from member elements encoding next in the stream diff --git a/src/Compilers/Core/Portable/Serialization/ObjectWriter.cs b/src/Compilers/Core/Portable/Serialization/ObjectWriter.cs index 517218dbb3b..83a011d1430 100644 --- a/src/Compilers/Core/Portable/Serialization/ObjectWriter.cs +++ b/src/Compilers/Core/Portable/Serialization/ObjectWriter.cs @@ -751,7 +751,10 @@ private void WriteObjectWorker(IObjectWritable writable) _objectReferenceMap.Add(writable); _writer.Write((byte)EncodingKind.Object); - this.WriteKnownType(writable.GetType()); + + // Directly write out the type-id for this object. i.e. no need to write out the 'Type' + // tag since we just wrote out the 'Object' tag + this.WriteInt32(_binderSnapshot.GetTypeId(writable.GetType())); writable.WriteTo(this); } -- GitLab