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

Function writeVarUint32

javascript/packages/hps/src/fastcall.cc:35–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33}
34
35uint32_t writeVarUint32(uint8_t *dst, uint32_t offset, int32_t value) {
36 if (value >> 7 == 0) {
37 dst[offset] = (uint8_t)value;
38 return 1;
39 }
40 if (value >> 14 == 0) {
41 dst[offset++] = (uint8_t)((value & 0x7F) | 0x80);
42 dst[offset++] = (uint8_t)(value >> 7);
43 return 2;
44 }
45 if (value >> 21 == 0) {
46 dst[offset++] = (uint8_t)((value & 0x7F) | 0x80);
47 dst[offset++] = (uint8_t)(value >> 7 | 0x80);
48 dst[offset++] = (uint8_t)(value >> 14);
49 return 3;
50 }
51 if (value >> 28 == 0) {
52 dst[offset++] = (uint8_t)((value & 0x7F) | 0x80);
53 dst[offset++] = (uint8_t)(value >> 7 | 0x80);
54 dst[offset++] = (uint8_t)(value >> 14 | 0x80);
55 dst[offset++] = (uint8_t)(value >> 21);
56 return 4;
57 }
58 dst[offset++] = (uint8_t)((value & 0x7F) | 0x80);
59 dst[offset++] = (uint8_t)(value >> 7 | 0x80);
60 dst[offset++] = (uint8_t)(value >> 14 | 0x80);
61 dst[offset++] = (uint8_t)(value >> 21 | 0x80);
62 dst[offset++] = (uint8_t)(value >> 28);
63 return 5;
64}
65
66enum Encoding { LATIN1, UTF16, UTF8 };
67

Callers 2

serializeStringFunction · 0.85
serializeStringFastFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected