@@ -39,17 +39,17 @@ public class DataTypeFieldSerialization : DataTypeSerialization
3939 public override void SetUp ( )
4040 {
4141 _fieldNullBuffer = new byte [ WireFormatting . GetFieldValueByteCount ( null ) ] ;
42- WireFormatting . WriteFieldValue ( _fieldNullBuffer . Span , null ) ;
42+ WireFormatting . WriteFieldValue ( ref _fieldNullBuffer . Span . GetStart ( ) , null ) ;
4343 _fieldIntBuffer = new byte [ WireFormatting . GetFieldValueByteCount ( _intObject ) ] ;
44- WireFormatting . WriteFieldValue ( _fieldIntBuffer . Span , _intObject ) ;
44+ WireFormatting . WriteFieldValue ( ref _fieldIntBuffer . Span . GetStart ( ) , _intObject ) ;
4545 _fieldStringBuffer = new byte [ WireFormatting . GetFieldValueByteCount ( _shortString ) ] ;
46- WireFormatting . WriteFieldValue ( _fieldStringBuffer . Span , _shortString ) ;
46+ WireFormatting . WriteFieldValue ( ref _fieldStringBuffer . Span . GetStart ( ) , _shortString ) ;
4747 _fieldArrayBuffer = new byte [ WireFormatting . GetFieldValueByteCount ( _byteArray ) ] ;
48- WireFormatting . WriteFieldValue ( _fieldArrayBuffer . Span , _byteArray ) ;
48+ WireFormatting . WriteFieldValue ( ref _fieldArrayBuffer . Span . GetStart ( ) , _byteArray ) ;
4949 _fieldDictBuffer = new byte [ WireFormatting . GetFieldValueByteCount ( _emptyDictionary ) ] ;
50- WireFormatting . WriteFieldValue ( _fieldDictBuffer . Span , _emptyDictionary ) ;
50+ WireFormatting . WriteFieldValue ( ref _fieldDictBuffer . Span . GetStart ( ) , _emptyDictionary ) ;
5151 _fieldBinaryTableValueBuffer = new byte [ WireFormatting . GetFieldValueByteCount ( _binaryTableValue ) ] ;
52- WireFormatting . WriteFieldValue ( _fieldBinaryTableValueBuffer . Span , _binaryTableValue ) ;
52+ WireFormatting . WriteFieldValue ( ref _fieldBinaryTableValueBuffer . Span . GetStart ( ) , _binaryTableValue ) ;
5353 }
5454
5555 [ Benchmark ]
@@ -64,20 +64,18 @@ public override void SetUp()
6464 public object DictRead ( ) => WireFormatting . ReadFieldValue ( _fieldDictBuffer . Span , out int _ ) ;
6565 [ Benchmark ]
6666 public object BinaryTableValueRead ( ) => WireFormatting . ReadFieldValue ( _fieldBinaryTableValueBuffer . Span , out int _ ) ;
67-
6867 [ Benchmark ]
69- public int NullWrite ( ) => WireFormatting . WriteFieldValue ( _buffer . Span , null ) ;
68+ public int NullWrite ( ) => WireFormatting . WriteFieldValue ( ref _buffer . Span . GetStart ( ) , null ) ;
7069 [ Benchmark ]
71- public int IntWrite ( ) => WireFormatting . WriteFieldValue ( _buffer . Span , _intObject ) ;
70+ public int IntWrite ( ) => WireFormatting . WriteFieldValue ( ref _buffer . Span . GetStart ( ) , _intObject ) ;
7271 [ Benchmark ]
73- public int StringWrite ( ) => WireFormatting . WriteFieldValue ( _buffer . Span , _shortString ) ;
72+ public int StringWrite ( ) => WireFormatting . WriteFieldValue ( ref _buffer . Span . GetStart ( ) , _shortString ) ;
7473 [ Benchmark ]
75- public int ArrayWrite ( ) => WireFormatting . WriteFieldValue ( _buffer . Span , _byteArray ) ;
74+ public int ArrayWrite ( ) => WireFormatting . WriteFieldValue ( ref _buffer . Span . GetStart ( ) , _byteArray ) ;
7675 [ Benchmark ]
77- public int DictWrite ( ) => WireFormatting . WriteFieldValue ( _buffer . Span , _emptyDictionary ) ;
76+ public int DictWrite ( ) => WireFormatting . WriteFieldValue ( ref _buffer . Span . GetStart ( ) , _emptyDictionary ) ;
7877 [ Benchmark ]
79- public int BinaryTableValueWrite ( ) => WireFormatting . WriteFieldValue ( _buffer . Span , _binaryTableValue ) ;
80-
78+ public int BinaryTableValueWrite ( ) => WireFormatting . WriteFieldValue ( ref _buffer . Span . GetStart ( ) , _binaryTableValue ) ;
8179 [ Benchmark ]
8280 public int NullGetSize ( ) => WireFormatting . GetFieldValueByteCount ( null ) ;
8381 [ Benchmark ]
@@ -103,10 +101,10 @@ public override void SetUp()
103101 {
104102 _array = new List < object > { "longstring" , 1234 , 12.34m , _timestamp } ;
105103 _emptyArrayBuffer = new byte [ WireFormatting . GetArrayByteCount ( _emptyArray ) ] ;
106- WireFormatting . WriteArray ( _emptyArrayBuffer . Span , _emptyArray ) ;
104+ WireFormatting . WriteArray ( ref _emptyArrayBuffer . Span . GetStart ( ) , _emptyArray ) ;
107105
108106 _populatedArrayBuffer = new byte [ WireFormatting . GetArrayByteCount ( _array ) ] ;
109- WireFormatting . WriteArray ( _populatedArrayBuffer . Span , _array ) ;
107+ WireFormatting . WriteArray ( ref _populatedArrayBuffer . Span . GetStart ( ) , _array ) ;
110108 }
111109
112110 [ Benchmark ]
@@ -116,10 +114,10 @@ public override void SetUp()
116114 public IList ArrayReadPopulated ( ) => WireFormatting . ReadArray ( _populatedArrayBuffer . Span , out _ ) ;
117115
118116 [ Benchmark ]
119- public int ArrayWriteEmpty ( ) => WireFormatting . WriteArray ( _buffer . Span , _emptyArray ) ;
117+ public int ArrayWriteEmpty ( ) => WireFormatting . WriteArray ( ref _buffer . Span . GetStart ( ) , _emptyArray ) ;
120118
121119 [ Benchmark ]
122- public int ArrayWritePopulated ( ) => WireFormatting . WriteArray ( _buffer . Span , _array ) ;
120+ public int ArrayWritePopulated ( ) => WireFormatting . WriteArray ( ref _buffer . Span . GetStart ( ) , _array ) ;
123121
124122 [ Benchmark ]
125123 public int ArrayGetSizeEmpty ( ) => WireFormatting . GetArrayByteCount ( _emptyArray ) ;
@@ -149,10 +147,10 @@ public override void SetUp()
149147 } ;
150148
151149 _emptyDictionaryBuffer = new byte [ WireFormatting . GetTableByteCount ( _emptyDict ) ] ;
152- WireFormatting . WriteTable ( _emptyDictionaryBuffer . Span , _emptyDict ) ;
150+ WireFormatting . WriteTable ( ref _emptyDictionaryBuffer . Span . GetStart ( ) , _emptyDict ) ;
153151
154152 _populatedDictionaryBuffer = new byte [ WireFormatting . GetTableByteCount ( _populatedDict ) ] ;
155- WireFormatting . WriteTable ( _populatedDictionaryBuffer . Span , _populatedDict ) ;
153+ WireFormatting . WriteTable ( ref _populatedDictionaryBuffer . Span . GetStart ( ) , _populatedDict ) ;
156154 }
157155
158156 [ Benchmark ]
@@ -162,10 +160,10 @@ public override void SetUp()
162160 public int TableReadPopulated ( ) => WireFormatting . ReadDictionary ( _populatedDictionaryBuffer . Span , out _ ) ;
163161
164162 [ Benchmark ]
165- public int TableWriteEmpty ( ) => WireFormatting . WriteTable ( _buffer . Span , _emptyDict ) ;
163+ public int TableWriteEmpty ( ) => WireFormatting . WriteTable ( ref _buffer . Span . GetStart ( ) , _emptyDict ) ;
166164
167165 [ Benchmark ]
168- public int TableWritePopulated ( ) => WireFormatting . WriteTable ( _buffer . Span , _populatedDict ) ;
166+ public int TableWritePopulated ( ) => WireFormatting . WriteTable ( ref _buffer . Span . GetStart ( ) , _populatedDict ) ;
169167
170168 [ Benchmark ]
171169 public int TableGetSizeEmpty ( ) => WireFormatting . GetTableByteCount ( _emptyDict ) ;
@@ -187,10 +185,10 @@ public class DataTypeLongStringSerialization : DataTypeSerialization
187185 public int LongstrReadPopulated ( ) => WireFormatting . ReadLongstr ( _populatedLongStringBuffer . Span , out _ ) ;
188186
189187 [ Benchmark ]
190- public int LongstrWriteEmpty ( ) => WireFormatting . WriteLongstr ( _buffer . Span , string . Empty ) ;
188+ public int LongstrWriteEmpty ( ) => WireFormatting . WriteLongstr ( ref _buffer . Span . GetStart ( ) , string . Empty ) ;
191189
192190 [ Benchmark ]
193- public int LongstrWritePopulated ( ) => WireFormatting . WriteLongstr ( _buffer . Span , _longString ) ;
191+ public int LongstrWritePopulated ( ) => WireFormatting . WriteLongstr ( ref _buffer . Span . GetStart ( ) , _longString ) ;
194192
195193 [ Benchmark ]
196194 public int LongstrGetSizeEmpty ( ) => WireFormatting . GetFieldValueByteCount ( string . Empty ) ;
@@ -201,7 +199,7 @@ public class DataTypeLongStringSerialization : DataTypeSerialization
201199 private static byte [ ] GenerateLongStringBuffer ( string val )
202200 {
203201 byte [ ] _buffer = new byte [ 5 + Encoding . UTF8 . GetByteCount ( val ) ] ;
204- WireFormatting . WriteLongstr ( _buffer , val ) ;
202+ WireFormatting . WriteLongstr ( ref _buffer . GetStart ( ) , val ) ;
205203 return _buffer ;
206204 }
207205 }
@@ -219,10 +217,10 @@ public class DataTypeShortStringSerialization : DataTypeSerialization
219217 public int ShortstrReadPopulated ( ) => WireFormatting . ReadShortstr ( _populatedShortStringBuffer . Span , out _ ) ;
220218
221219 [ Benchmark ]
222- public int ShortstrWriteEmpty ( ) => WireFormatting . WriteShortstr ( _buffer . Span , string . Empty ) ;
220+ public int ShortstrWriteEmpty ( ) => WireFormatting . WriteShortstr ( ref _buffer . Span . GetStart ( ) , string . Empty ) ;
223221
224222 [ Benchmark ]
225- public int ShortstrWritePopulated ( ) => WireFormatting . WriteShortstr ( _buffer . Span , _shortString ) ;
223+ public int ShortstrWritePopulated ( ) => WireFormatting . WriteShortstr ( ref _buffer . Span . GetStart ( ) , _shortString ) ;
226224
227225 [ Benchmark ]
228226 public int ShortstrGetSizeEmpty ( ) => WireFormatting . GetByteCount ( string . Empty ) ;
@@ -233,7 +231,7 @@ public class DataTypeShortStringSerialization : DataTypeSerialization
233231 private static byte [ ] GenerateStringBuffer ( string val )
234232 {
235233 byte [ ] _buffer = new byte [ 2 + Encoding . UTF8 . GetByteCount ( val ) ] ;
236- WireFormatting . WriteShortstr ( _buffer , val ) ;
234+ WireFormatting . WriteShortstr ( ref _buffer . GetStart ( ) , val ) ;
237235 return _buffer ;
238236 }
239237 }
0 commit comments