From 1f56e5e2a4a3bacea521702b05e717bd2b494ed4 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 23 Jun 2020 15:40:39 +0200 Subject: [PATCH] remove AggressiveInlining attribute from WritingPrimitives.cs --- .../src/Google.Protobuf/WritingPrimitives.cs | 37 ------------------- 1 file changed, 37 deletions(-) diff --git a/csharp/src/Google.Protobuf/WritingPrimitives.cs b/csharp/src/Google.Protobuf/WritingPrimitives.cs index 6b48af1e3c..79a691fead 100644 --- a/csharp/src/Google.Protobuf/WritingPrimitives.cs +++ b/csharp/src/Google.Protobuf/WritingPrimitives.cs @@ -53,7 +53,6 @@ namespace Google.Protobuf /// /// Writes a double field value, without a tag, to the stream. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteDouble(ref Span buffer, ref WriterInternalState state, double value) { WriteRawLittleEndian64(ref buffer, ref state, (ulong)BitConverter.DoubleToInt64Bits(value)); @@ -62,7 +61,6 @@ namespace Google.Protobuf /// /// Writes a float field value, without a tag, to the stream. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static unsafe void WriteFloat(ref Span buffer, ref WriterInternalState state, float value) { const int length = sizeof(float); @@ -98,7 +96,6 @@ namespace Google.Protobuf /// /// Writes a uint64 field value, without a tag, to the stream. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteUInt64(ref Span buffer, ref WriterInternalState state, ulong value) { WriteRawVarint64(ref buffer, ref state, value); @@ -107,7 +104,6 @@ namespace Google.Protobuf /// /// Writes an int64 field value, without a tag, to the stream. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteInt64(ref Span buffer, ref WriterInternalState state, long value) { WriteRawVarint64(ref buffer, ref state, (ulong)value); @@ -116,7 +112,6 @@ namespace Google.Protobuf /// /// Writes an int32 field value, without a tag, to the stream. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteInt32(ref Span buffer, ref WriterInternalState state, int value) { if (value >= 0) @@ -133,7 +128,6 @@ namespace Google.Protobuf /// /// Writes a fixed64 field value, without a tag, to the stream. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteFixed64(ref Span buffer, ref WriterInternalState state, ulong value) { WriteRawLittleEndian64(ref buffer, ref state, value); @@ -142,7 +136,6 @@ namespace Google.Protobuf /// /// Writes a fixed32 field value, without a tag, to the stream. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteFixed32(ref Span buffer, ref WriterInternalState state, uint value) { WriteRawLittleEndian32(ref buffer, ref state, value); @@ -151,7 +144,6 @@ namespace Google.Protobuf /// /// Writes a bool field value, without a tag, to the stream. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteBool(ref Span buffer, ref WriterInternalState state, bool value) { WriteRawByte(ref buffer, ref state, value ? (byte)1 : (byte)0); @@ -161,7 +153,6 @@ namespace Google.Protobuf /// Writes a string field value, without a tag, to the stream. /// The data is length-prefixed. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteString(ref Span buffer, ref WriterInternalState state, string value) { // Optimise the case where we have enough space to write @@ -214,7 +205,6 @@ namespace Google.Protobuf /// Write a byte string, without a tag, to the stream. /// The data is length-prefixed. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteBytes(ref Span buffer, ref WriterInternalState state, ByteString value) { WriteLength(ref buffer, ref state, value.Length); @@ -224,7 +214,6 @@ namespace Google.Protobuf /// /// Writes a uint32 value, without a tag, to the stream. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteUInt32(ref Span buffer, ref WriterInternalState state, uint value) { WriteRawVarint32(ref buffer, ref state, value); @@ -233,7 +222,6 @@ namespace Google.Protobuf /// /// Writes an enum value, without a tag, to the stream. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteEnum(ref Span buffer, ref WriterInternalState state, int value) { WriteInt32(ref buffer, ref state, value); @@ -242,7 +230,6 @@ namespace Google.Protobuf /// /// Writes an sfixed32 value, without a tag, to the stream. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteSFixed32(ref Span buffer, ref WriterInternalState state, int value) { WriteRawLittleEndian32(ref buffer, ref state, (uint)value); @@ -251,7 +238,6 @@ namespace Google.Protobuf /// /// Writes an sfixed64 value, without a tag, to the stream. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteSFixed64(ref Span buffer, ref WriterInternalState state, long value) { WriteRawLittleEndian64(ref buffer, ref state, (ulong)value); @@ -260,7 +246,6 @@ namespace Google.Protobuf /// /// Writes an sint32 value, without a tag, to the stream. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteSInt32(ref Span buffer, ref WriterInternalState state, int value) { WriteRawVarint32(ref buffer, ref state, EncodeZigZag32(value)); @@ -269,7 +254,6 @@ namespace Google.Protobuf /// /// Writes an sint64 value, without a tag, to the stream. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteSInt64(ref Span buffer, ref WriterInternalState state, long value) { WriteRawVarint64(ref buffer, ref state, EncodeZigZag64(value)); @@ -281,8 +265,6 @@ namespace Google.Protobuf /// /// This method simply writes a rawint, but exists for clarity in calling code. /// - - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteLength(ref Span buffer, ref WriterInternalState state, int length) { WriteRawVarint32(ref buffer, ref state, (uint)length); @@ -296,7 +278,6 @@ namespace Google.Protobuf /// there's enough buffer space left to whizz through without checking /// for each byte; otherwise, we resort to calling WriteRawByte each time. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteRawVarint32(ref Span buffer, ref WriterInternalState state, uint value) { // Optimize for the common case of a single byte value @@ -326,7 +307,6 @@ namespace Google.Protobuf } } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteRawVarint64(ref Span buffer, ref WriterInternalState state, ulong value) { while (value > 127 && state.position < state.limit) @@ -349,7 +329,6 @@ namespace Google.Protobuf } } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteRawLittleEndian32(ref Span buffer, ref WriterInternalState state, uint value) { const int length = sizeof(uint); @@ -367,7 +346,6 @@ namespace Google.Protobuf } } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteRawLittleEndian64(ref Span buffer, ref WriterInternalState state, ulong value) { const int length = sizeof(ulong); @@ -399,11 +377,6 @@ namespace Google.Protobuf } } - // This method is intentionally not marked as "AggressiveInlining", because it slows down - // serialization of messages with lots of empty fields. Likely explanation is that - // thw WriteRawTag invocations in InternalWriteTo method get inlined too deep and that makes - // skipping fields which are not present more expensive (which is especially constly for - // messages with lots of fields of which only a few are present). public static void WriteRawByte(ref Span buffer, ref WriterInternalState state, byte value) { if (state.position == state.limit) @@ -417,7 +390,6 @@ namespace Google.Protobuf /// /// Writes out an array of bytes. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteRawBytes(ref Span buffer, ref WriterInternalState state, byte[] value) { WriteRawBytes(ref buffer, ref state, new ReadOnlySpan(value)); @@ -426,7 +398,6 @@ namespace Google.Protobuf /// /// Writes out part of an array of bytes. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteRawBytes(ref Span buffer, ref WriterInternalState state, byte[] value, int offset, int length) { WriteRawBytes(ref buffer, ref state, new ReadOnlySpan(value, offset, length)); @@ -435,7 +406,6 @@ namespace Google.Protobuf /// /// Writes out part of an array of bytes. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteRawBytes(ref Span buffer, ref WriterInternalState state, ReadOnlySpan value) { if (state.limit - state.position >= value.Length) @@ -474,7 +444,6 @@ namespace Google.Protobuf /// /// Encodes and writes a tag. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteTag(ref Span buffer, ref WriterInternalState state, int fieldNumber, WireFormat.WireType type) { WriteRawVarint32(ref buffer, ref state, WireFormat.MakeTag(fieldNumber, type)); @@ -483,7 +452,6 @@ namespace Google.Protobuf /// /// Writes an already-encoded tag. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteTag(ref Span buffer, ref WriterInternalState state, uint tag) { WriteRawVarint32(ref buffer, ref state, tag); @@ -492,7 +460,6 @@ namespace Google.Protobuf /// /// Writes the given single-byte tag directly to the stream. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteRawTag(ref Span buffer, ref WriterInternalState state, byte b1) { WriteRawByte(ref buffer, ref state, b1); @@ -501,7 +468,6 @@ namespace Google.Protobuf /// /// Writes the given two-byte tag directly to the stream. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteRawTag(ref Span buffer, ref WriterInternalState state, byte b1, byte b2) { WriteRawByte(ref buffer, ref state, b1); @@ -511,7 +477,6 @@ namespace Google.Protobuf /// /// Writes the given three-byte tag directly to the stream. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteRawTag(ref Span buffer, ref WriterInternalState state, byte b1, byte b2, byte b3) { WriteRawByte(ref buffer, ref state, b1); @@ -522,7 +487,6 @@ namespace Google.Protobuf /// /// Writes the given four-byte tag directly to the stream. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteRawTag(ref Span buffer, ref WriterInternalState state, byte b1, byte b2, byte b3, byte b4) { WriteRawByte(ref buffer, ref state, b1); @@ -534,7 +498,6 @@ namespace Google.Protobuf /// /// Writes the given five-byte tag directly to the stream. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteRawTag(ref Span buffer, ref WriterInternalState state, byte b1, byte b2, byte b3, byte b4, byte b5) { WriteRawByte(ref buffer, ref state, b1);