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

Method WriteVarUInt32

csharp/src/Fory/ByteBuffer.cs:127–172  ·  view source on GitHub ↗
(uint value)

Source from the content-addressed store, hash-verified

125 }
126
127 [MethodImpl(MethodImplOptions.AggressiveInlining)]
128 public void WriteVarUInt32(uint value)
129 {
130 EnsureCapacity(5);
131 int index = _count;
132 if (value < (1u << 7))
133 {
134 _storage[index] = unchecked((byte)value);
135 _count = index + 1;
136 return;
137 }
138
139 if (value < (1u << 14))
140 {
141 _storage[index] = unchecked((byte)((value & 0x7Fu) | 0x80u));
142 _storage[index + 1] = unchecked((byte)(value >> 7));
143 _count = index + 2;
144 return;
145 }
146
147 if (value < (1u << 21))
148 {
149 _storage[index] = unchecked((byte)((value & 0x7Fu) | 0x80u));
150 _storage[index + 1] = unchecked((byte)(((value >> 7) & 0x7Fu) | 0x80u));
151 _storage[index + 2] = unchecked((byte)(value >> 14));
152 _count = index + 3;
153 return;
154 }
155
156 if (value < (1u << 28))
157 {
158 _storage[index] = unchecked((byte)((value & 0x7Fu) | 0x80u));
159 _storage[index + 1] = unchecked((byte)(((value >> 7) & 0x7Fu) | 0x80u));
160 _storage[index + 2] = unchecked((byte)(((value >> 14) & 0x7Fu) | 0x80u));
161 _storage[index + 3] = unchecked((byte)(value >> 21));
162 _count = index + 4;
163 return;
164 }
165
166 _storage[index] = unchecked((byte)((value & 0x7Fu) | 0x80u));
167 _storage[index + 1] = unchecked((byte)(((value >> 7) & 0x7Fu) | 0x80u));
168 _storage[index + 2] = unchecked((byte)(((value >> 14) & 0x7Fu) | 0x80u));
169 _storage[index + 3] = unchecked((byte)(((value >> 21) & 0x7Fu) | 0x80u));
170 _storage[index + 4] = unchecked((byte)(value >> 28));
171 _count = index + 5;
172 }
173
174 [MethodImpl(MethodImplOptions.AggressiveInlining)]
175 public void WriteVarUInt64(ulong value)

Callers 15

WriteDataMethod · 0.80
WriteDataMethod · 0.80
WriteCollectionDataMethod · 0.80
WriteMethod · 0.80
WriteMapMethod · 0.80
WriteTypeMetaMethod · 0.80
WriteListHeaderMethod · 0.80
WriteDataMethod · 0.80
WriteDataMethod · 0.80
WriteDataMethod · 0.80
WriteDataMethod · 0.80
WriteDataMethod · 0.80

Calls

no outgoing calls

Tested by 7

ReadAndStoreTypeMetaMethod · 0.64
ReadAnyTypeInfoMethod · 0.64
RewriteRootUserTypeIdMethod · 0.64
CaseBufferMethod · 0.64
CaseBufferVarMethod · 0.64