@@ -41,16 +41,16 @@ private static int WriteString(Span<byte> seq, string value)
4141 // Str8
4242 if ( len <= byte . MaxValue )
4343 {
44- offset += WireFormatting . WriteByte ( seq . Slice ( offset ) , FormatCode . Str8 ) ;
45- offset += WireFormatting . WriteByte ( seq . Slice ( offset ) , ( byte ) len ) ;
46- offset += s_encoding . GetBytes ( value , seq . Slice ( offset ) ) ;
44+ offset += WireFormatting . WriteByte ( seq [ offset .. ] , FormatCode . Str8 ) ;
45+ offset += WireFormatting . WriteByte ( seq [ offset .. ] , ( byte ) len ) ;
46+ offset += s_encoding . GetBytes ( value , seq [ offset .. ] ) ;
4747 return offset ;
4848 }
4949
5050 // Str32
51- offset += WireFormatting . WriteByte ( seq . Slice ( offset ) , FormatCode . Str32 ) ;
52- offset += WireFormatting . WriteInt32 ( seq . Slice ( offset ) , len ) ;
53- offset += s_encoding . GetBytes ( value , seq . Slice ( offset ) ) ;
51+ offset += WireFormatting . WriteByte ( seq [ offset .. ] , FormatCode . Str32 ) ;
52+ offset += WireFormatting . WriteInt32 ( seq [ offset .. ] , len ) ;
53+ offset += s_encoding . GetBytes ( value , seq [ offset .. ] ) ;
5454 return offset ;
5555 }
5656
@@ -64,13 +64,13 @@ private static int WriteUInt64(Span<byte> seq, ulong value)
6464 var offset = 0 ;
6565 if ( value < 256 )
6666 {
67- offset += WireFormatting . WriteByte ( seq . Slice ( offset ) , FormatCode . SmallUlong ) ;
68- offset += WireFormatting . WriteByte ( seq . Slice ( offset ) , ( byte ) value ) ;
67+ offset += WireFormatting . WriteByte ( seq [ offset .. ] , FormatCode . SmallUlong ) ;
68+ offset += WireFormatting . WriteByte ( seq [ offset .. ] , ( byte ) value ) ;
6969 return offset ;
7070 }
7171
72- offset += WireFormatting . WriteByte ( seq . Slice ( offset ) , FormatCode . Ulong ) ;
73- offset += WireFormatting . WriteUInt64 ( seq . Slice ( offset ) , value ) ;
72+ offset += WireFormatting . WriteByte ( seq [ offset .. ] , FormatCode . Ulong ) ;
73+ offset += WireFormatting . WriteUInt64 ( seq [ offset .. ] , value ) ;
7474 return offset ;
7575 }
7676
@@ -83,13 +83,13 @@ private static int WriteUInt(Span<byte> seq, uint value)
8383 case 0 :
8484 return WireFormatting . WriteByte ( seq , FormatCode . Uint0 ) ;
8585 case < 256 :
86- offset += WireFormatting . WriteByte ( seq . Slice ( offset ) , FormatCode . SmallUint ) ;
87- offset += WireFormatting . WriteByte ( seq . Slice ( offset ) , ( byte ) value ) ;
86+ offset += WireFormatting . WriteByte ( seq [ offset .. ] , FormatCode . SmallUint ) ;
87+ offset += WireFormatting . WriteByte ( seq [ offset .. ] , ( byte ) value ) ;
8888 return offset ;
8989 }
9090
91- offset += WireFormatting . WriteByte ( seq . Slice ( offset ) , FormatCode . Uint ) ;
92- offset += WireFormatting . WriteUInt32 ( seq . Slice ( offset ) , value ) ;
91+ offset += WireFormatting . WriteByte ( seq [ offset .. ] , FormatCode . Uint ) ;
92+ offset += WireFormatting . WriteUInt32 ( seq [ offset .. ] , value ) ;
9393 return offset ;
9494 }
9595
@@ -98,14 +98,14 @@ private static int WriteInt(Span<byte> seq, int value)
9898 var offset = 0 ;
9999 if ( value is < 128 and >= - 128 )
100100 {
101- offset += WireFormatting . WriteByte ( seq . Slice ( offset ) , FormatCode . Smallint ) ;
102- offset += WireFormatting . WriteByte ( seq . Slice ( offset ) , ( byte ) value ) ;
101+ offset += WireFormatting . WriteByte ( seq [ offset .. ] , FormatCode . Smallint ) ;
102+ offset += WireFormatting . WriteByte ( seq [ offset .. ] , ( byte ) value ) ;
103103
104104 return offset ;
105105 }
106106
107- offset += WireFormatting . WriteByte ( seq . Slice ( offset ) , FormatCode . Int ) ;
108- offset += WireFormatting . WriteInt32 ( seq . Slice ( offset ) , value ) ;
107+ offset += WireFormatting . WriteByte ( seq [ offset .. ] , FormatCode . Int ) ;
108+ offset += WireFormatting . WriteInt32 ( seq [ offset .. ] , value ) ;
109109 return offset ;
110110 }
111111
@@ -114,14 +114,14 @@ private static int WriteInt64(Span<byte> seq, long value)
114114 var offset = 0 ;
115115 if ( value is < 128 and >= - 128 )
116116 {
117- offset += WireFormatting . WriteByte ( seq . Slice ( offset ) , FormatCode . Smalllong ) ;
118- offset += WireFormatting . WriteByte ( seq . Slice ( offset ) , ( byte ) value ) ;
117+ offset += WireFormatting . WriteByte ( seq [ offset .. ] , FormatCode . Smalllong ) ;
118+ offset += WireFormatting . WriteByte ( seq [ offset .. ] , ( byte ) value ) ;
119119
120120 return offset ;
121121 }
122122
123- offset += WireFormatting . WriteByte ( seq . Slice ( offset ) , FormatCode . Long ) ;
124- offset += WireFormatting . WriteInt64 ( seq . Slice ( offset ) , value ) ;
123+ offset += WireFormatting . WriteByte ( seq [ offset .. ] , FormatCode . Long ) ;
124+ offset += WireFormatting . WriteInt64 ( seq [ offset .. ] , value ) ;
125125 return offset ;
126126 }
127127
@@ -138,60 +138,60 @@ private static int WriteBytes(Span<byte> seq, byte[] value)
138138 // List8
139139 if ( len < 256 )
140140 {
141- offset += WireFormatting . WriteByte ( seq . Slice ( offset ) , FormatCode . Vbin8 ) ;
142- offset += WireFormatting . WriteByte ( seq . Slice ( offset ) , ( byte ) len ) ;
143- offset += WireFormatting . Write ( seq . Slice ( offset ) , new ReadOnlySequence < byte > ( value ) ) ;
141+ offset += WireFormatting . WriteByte ( seq [ offset .. ] , FormatCode . Vbin8 ) ;
142+ offset += WireFormatting . WriteByte ( seq [ offset .. ] , ( byte ) len ) ;
143+ offset += WireFormatting . Write ( seq [ offset .. ] , new ReadOnlySequence < byte > ( value ) ) ;
144144 return offset ;
145145 }
146146
147147 // List32
148- offset += WireFormatting . WriteByte ( seq . Slice ( offset ) , FormatCode . Vbin32 ) ;
149- offset += WireFormatting . WriteUInt32 ( seq . Slice ( offset ) , ( uint ) len ) ;
150- offset += WireFormatting . Write ( seq . Slice ( offset ) , new ReadOnlySequence < byte > ( value ) ) ;
148+ offset += WireFormatting . WriteByte ( seq [ offset .. ] , FormatCode . Vbin32 ) ;
149+ offset += WireFormatting . WriteUInt32 ( seq [ offset .. ] , ( uint ) len ) ;
150+ offset += WireFormatting . Write ( seq [ offset .. ] , new ReadOnlySequence < byte > ( value ) ) ;
151151 return offset ;
152152 }
153153
154154 private static int WriteUInt16 ( Span < byte > seq , ushort value )
155155 {
156156 var offset = WireFormatting . WriteByte ( seq , FormatCode . Ushort ) ;
157- offset += WireFormatting . WriteUInt16 ( seq . Slice ( offset ) , value ) ;
157+ offset += WireFormatting . WriteUInt16 ( seq [ offset .. ] , value ) ;
158158 return offset ;
159159 }
160160
161161 private static int WriteByte ( Span < byte > seq , byte value )
162162 {
163163 var offset = WireFormatting . WriteByte ( seq , FormatCode . Ubyte ) ;
164- offset += WireFormatting . WriteByte ( seq . Slice ( offset ) , value ) ;
164+ offset += WireFormatting . WriteByte ( seq [ offset .. ] , value ) ;
165165 return offset ;
166166 }
167167
168168 private static int WriteSByte ( Span < byte > seq , sbyte value )
169169 {
170170 var offset = WireFormatting . WriteByte ( seq , FormatCode . Byte ) ;
171- offset += WireFormatting . WriteByte ( seq . Slice ( offset ) , ( byte ) value ) ;
171+ offset += WireFormatting . WriteByte ( seq [ offset .. ] , ( byte ) value ) ;
172172 return offset ;
173173 }
174174
175175 private static int WriteFloat ( Span < byte > seq , float value )
176176 {
177177 var offset = WireFormatting . WriteByte ( seq , FormatCode . Float ) ;
178178 var intFloat = BitConverter . SingleToInt32Bits ( value ) ;
179- offset += WireFormatting . WriteInt32 ( seq . Slice ( offset ) , intFloat ) ;
179+ offset += WireFormatting . WriteInt32 ( seq [ offset .. ] , intFloat ) ;
180180 return offset ;
181181 }
182182
183183 private static int WriteDouble ( Span < byte > seq , double value )
184184 {
185185 var offset = WireFormatting . WriteByte ( seq , FormatCode . Double ) ;
186186 var intFloat = BitConverter . DoubleToInt64Bits ( value ) ;
187- offset += WireFormatting . WriteInt64 ( seq . Slice ( offset ) , intFloat ) ;
187+ offset += WireFormatting . WriteInt64 ( seq [ offset .. ] , intFloat ) ;
188188 return offset ;
189189 }
190190
191191 private static int WriteIn16 ( Span < byte > seq , short value )
192192 {
193193 var offset = WireFormatting . WriteByte ( seq , FormatCode . Short ) ;
194- offset += WireFormatting . WriteInt16 ( seq . Slice ( offset ) , value ) ;
194+ offset += WireFormatting . WriteInt16 ( seq [ offset .. ] , value ) ;
195195 return offset ;
196196 }
197197
@@ -204,7 +204,7 @@ private static int WriteTimestamp(Span<byte> seq, DateTime value)
204204 {
205205 var offset = WireFormatting . WriteByte ( seq , FormatCode . Timestamp ) ;
206206 var unixTime = ( ( DateTimeOffset ) value ) . ToUnixTimeMilliseconds ( ) ;
207- offset += WireFormatting . WriteUInt64 ( seq . Slice ( offset ) , ( ulong ) unixTime ) ;
207+ offset += WireFormatting . WriteUInt64 ( seq [ offset .. ] , ( ulong ) unixTime ) ;
208208 return offset ;
209209 }
210210
0 commit comments