MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / EncodeVarint32

Function EncodeVarint32

src/leveldb/util/coding.cc:47–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47char* EncodeVarint32(char* dst, uint32_t v) {
48 // Operate on characters as unsigneds
49 unsigned char* ptr = reinterpret_cast<unsigned char*>(dst);
50 static const int B = 128;
51 if (v < (1<<7)) {
52 *(ptr++) = v;
53 } else if (v < (1<<14)) {
54 *(ptr++) = v | B;
55 *(ptr++) = v>>7;
56 } else if (v < (1<<21)) {
57 *(ptr++) = v | B;
58 *(ptr++) = (v>>7) | B;
59 *(ptr++) = v>>14;
60 } else if (v < (1<<28)) {
61 *(ptr++) = v | B;
62 *(ptr++) = (v>>7) | B;
63 *(ptr++) = (v>>14) | B;
64 *(ptr++) = v>>21;
65 } else {
66 *(ptr++) = v | B;
67 *(ptr++) = (v>>7) | B;
68 *(ptr++) = (v>>14) | B;
69 *(ptr++) = (v>>21) | B;
70 *(ptr++) = v>>28;
71 }
72 return reinterpret_cast<char*>(ptr);
73}
74
75void PutVarint32(std::string* dst, uint32_t v) {
76 char buf[5];

Callers 3

PutVarint32Function · 0.85
AddMethod · 0.85
LookupKeyMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected