MCPcopy Create free account
hub / github.com/apache/fory / WriteVarUInt64

Method WriteVarUInt64

csharp/src/Fory/ByteBuffer.cs:174–273  ·  view source on GitHub ↗
(ulong value)

Source from the content-addressed store, hash-verified

172 }
173
174 [MethodImpl(MethodImplOptions.AggressiveInlining)]
175 public void WriteVarUInt64(ulong value)
176 {
177 EnsureCapacity(9);
178 int index = _count;
179 if (value < (1UL << 7))
180 {
181 _storage[index] = unchecked((byte)value);
182 _count = index + 1;
183 return;
184 }
185
186 if (value < (1UL << 14))
187 {
188 _storage[index] = unchecked((byte)((value & 0x7FuL) | 0x80uL));
189 _storage[index + 1] = unchecked((byte)(value >> 7));
190 _count = index + 2;
191 return;
192 }
193
194 if (value < (1UL << 21))
195 {
196 _storage[index] = unchecked((byte)((value & 0x7FuL) | 0x80uL));
197 _storage[index + 1] = unchecked((byte)(((value >> 7) & 0x7FuL) | 0x80uL));
198 _storage[index + 2] = unchecked((byte)(value >> 14));
199 _count = index + 3;
200 return;
201 }
202
203 if (value < (1UL << 28))
204 {
205 _storage[index] = unchecked((byte)((value & 0x7FuL) | 0x80uL));
206 _storage[index + 1] = unchecked((byte)(((value >> 7) & 0x7FuL) | 0x80uL));
207 _storage[index + 2] = unchecked((byte)(((value >> 14) & 0x7FuL) | 0x80uL));
208 _storage[index + 3] = unchecked((byte)(value >> 21));
209 _count = index + 4;
210 return;
211 }
212
213 if (value < (1UL << 35))
214 {
215 _storage[index] = unchecked((byte)((value & 0x7FuL) | 0x80uL));
216 _storage[index + 1] = unchecked((byte)(((value >> 7) & 0x7FuL) | 0x80uL));
217 _storage[index + 2] = unchecked((byte)(((value >> 14) & 0x7FuL) | 0x80uL));
218 _storage[index + 3] = unchecked((byte)(((value >> 21) & 0x7FuL) | 0x80uL));
219 _storage[index + 4] = unchecked((byte)(value >> 28));
220 _count = index + 5;
221 return;
222 }
223
224 if (value < (1UL << 42))
225 {
226 _storage[index] = unchecked((byte)((value & 0x7FuL) | 0x80uL));
227 _storage[index + 1] = unchecked((byte)(((value >> 7) & 0x7FuL) | 0x80uL));
228 _storage[index + 2] = unchecked((byte)(((value >> 14) & 0x7FuL) | 0x80uL));
229 _storage[index + 3] = unchecked((byte)(((value >> 21) & 0x7FuL) | 0x80uL));
230 _storage[index + 4] = unchecked((byte)(((value >> 28) & 0x7FuL) | 0x80uL));
231 _storage[index + 5] = unchecked((byte)(value >> 35));

Callers 11

WriteMethod · 0.80
WriteDataMethod · 0.80
WriteMethod · 0.80
WriteDataMethod · 0.80
WriteDataMethod · 0.80
TryWriteKnownPayloadMethod · 0.80
WriteTypedPayloadMethod · 0.80
CaseBufferVarMethod · 0.80

Calls

no outgoing calls