MCPcopy Create free account
hub / github.com/ccache/ccache / format_base32hex

Function format_base32hex

src/ccache/util/string.cpp:143–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141}
142
143std::string
144format_base32hex(std::span<const uint8_t> data)
145{
146 static const char digits[] = "0123456789abcdefghijklmnopqrstuv";
147 std::string result;
148 result.reserve(data.size() * 8 / 5 + 1);
149 uint8_t i = 0;
150 uint16_t bits = 0;
151 for (uint8_t b : data) {
152 bits <<= 8;
153 bits |= b;
154 i += 8;
155 while (i >= 5) {
156 result += digits[(bits >> (i - 5)) & 0x1f];
157 i -= 5;
158 }
159 }
160 if (i > 0) {
161 DEBUG_ASSERT(i < 5);
162 result += digits[(bits << (5 - i)) & 0x1f];
163 }
164 return result;
165}
166
167std::string
168format_legacy_digest(std::span<const uint8_t> data)

Callers 2

format_legacy_digestFunction · 0.85

Calls 2

reserveMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected