@@ -41,16 +41,16 @@ private static int WriteString(Span<byte> seq, string value)
41
41
// Str8
42
42
if ( len <= byte . MaxValue )
43
43
{
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 .. ] ) ;
47
47
return offset ;
48
48
}
49
49
50
50
// 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 .. ] ) ;
54
54
return offset ;
55
55
}
56
56
@@ -64,13 +64,13 @@ private static int WriteUInt64(Span<byte> seq, ulong value)
64
64
var offset = 0 ;
65
65
if ( value < 256 )
66
66
{
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 ) ;
69
69
return offset ;
70
70
}
71
71
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 ) ;
74
74
return offset ;
75
75
}
76
76
@@ -83,13 +83,13 @@ private static int WriteUInt(Span<byte> seq, uint value)
83
83
case 0 :
84
84
return WireFormatting . WriteByte ( seq , FormatCode . Uint0 ) ;
85
85
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 ) ;
88
88
return offset ;
89
89
}
90
90
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 ) ;
93
93
return offset ;
94
94
}
95
95
@@ -98,14 +98,14 @@ private static int WriteInt(Span<byte> seq, int value)
98
98
var offset = 0 ;
99
99
if ( value is < 128 and >= - 128 )
100
100
{
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 ) ;
103
103
104
104
return offset ;
105
105
}
106
106
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 ) ;
109
109
return offset ;
110
110
}
111
111
@@ -114,14 +114,14 @@ private static int WriteInt64(Span<byte> seq, long value)
114
114
var offset = 0 ;
115
115
if ( value is < 128 and >= - 128 )
116
116
{
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 ) ;
119
119
120
120
return offset ;
121
121
}
122
122
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 ) ;
125
125
return offset ;
126
126
}
127
127
@@ -138,60 +138,60 @@ private static int WriteBytes(Span<byte> seq, byte[] value)
138
138
// List8
139
139
if ( len < 256 )
140
140
{
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 ) ) ;
144
144
return offset ;
145
145
}
146
146
147
147
// 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 ) ) ;
151
151
return offset ;
152
152
}
153
153
154
154
private static int WriteUInt16 ( Span < byte > seq , ushort value )
155
155
{
156
156
var offset = WireFormatting . WriteByte ( seq , FormatCode . Ushort ) ;
157
- offset += WireFormatting . WriteUInt16 ( seq . Slice ( offset ) , value ) ;
157
+ offset += WireFormatting . WriteUInt16 ( seq [ offset .. ] , value ) ;
158
158
return offset ;
159
159
}
160
160
161
161
private static int WriteByte ( Span < byte > seq , byte value )
162
162
{
163
163
var offset = WireFormatting . WriteByte ( seq , FormatCode . Ubyte ) ;
164
- offset += WireFormatting . WriteByte ( seq . Slice ( offset ) , value ) ;
164
+ offset += WireFormatting . WriteByte ( seq [ offset .. ] , value ) ;
165
165
return offset ;
166
166
}
167
167
168
168
private static int WriteSByte ( Span < byte > seq , sbyte value )
169
169
{
170
170
var offset = WireFormatting . WriteByte ( seq , FormatCode . Byte ) ;
171
- offset += WireFormatting . WriteByte ( seq . Slice ( offset ) , ( byte ) value ) ;
171
+ offset += WireFormatting . WriteByte ( seq [ offset .. ] , ( byte ) value ) ;
172
172
return offset ;
173
173
}
174
174
175
175
private static int WriteFloat ( Span < byte > seq , float value )
176
176
{
177
177
var offset = WireFormatting . WriteByte ( seq , FormatCode . Float ) ;
178
178
var intFloat = BitConverter . SingleToInt32Bits ( value ) ;
179
- offset += WireFormatting . WriteInt32 ( seq . Slice ( offset ) , intFloat ) ;
179
+ offset += WireFormatting . WriteInt32 ( seq [ offset .. ] , intFloat ) ;
180
180
return offset ;
181
181
}
182
182
183
183
private static int WriteDouble ( Span < byte > seq , double value )
184
184
{
185
185
var offset = WireFormatting . WriteByte ( seq , FormatCode . Double ) ;
186
186
var intFloat = BitConverter . DoubleToInt64Bits ( value ) ;
187
- offset += WireFormatting . WriteInt64 ( seq . Slice ( offset ) , intFloat ) ;
187
+ offset += WireFormatting . WriteInt64 ( seq [ offset .. ] , intFloat ) ;
188
188
return offset ;
189
189
}
190
190
191
191
private static int WriteIn16 ( Span < byte > seq , short value )
192
192
{
193
193
var offset = WireFormatting . WriteByte ( seq , FormatCode . Short ) ;
194
- offset += WireFormatting . WriteInt16 ( seq . Slice ( offset ) , value ) ;
194
+ offset += WireFormatting . WriteInt16 ( seq [ offset .. ] , value ) ;
195
195
return offset ;
196
196
}
197
197
@@ -204,7 +204,7 @@ private static int WriteTimestamp(Span<byte> seq, DateTime value)
204
204
{
205
205
var offset = WireFormatting . WriteByte ( seq , FormatCode . Timestamp ) ;
206
206
var unixTime = ( ( DateTimeOffset ) value ) . ToUnixTimeMilliseconds ( ) ;
207
- offset += WireFormatting . WriteUInt64 ( seq . Slice ( offset ) , ( ulong ) unixTime ) ;
207
+ offset += WireFormatting . WriteUInt64 ( seq [ offset .. ] , ( ulong ) unixTime ) ;
208
208
return offset ;
209
209
}
210
210
0 commit comments