MCPcopy Create free account
hub / github.com/apache/brpc / fast_rand_bytes

Function fast_rand_bytes

src/butil/fast_rand.cpp:177–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175}
176
177void fast_rand_bytes(void* output, size_t output_length) {
178 const size_t n = output_length / 8;
179 for (size_t i = 0; i < n; ++i) {
180 static_cast<uint64_t*>(output)[i] = fast_rand();
181 }
182 const size_t m = output_length - n * 8;
183 if (m) {
184 uint8_t* p = static_cast<uint8_t*>(output) + n * 8;
185 uint64_t r = fast_rand();
186 for (size_t i = 0; i < m; ++i) {
187 p[i] = (r & 0xFF);
188 r = (r >> 8);
189 }
190 }
191}
192
193std::string fast_rand_printable(size_t length) {
194 std::string result(length, 0);

Callers 2

PerformanceTestMethod · 0.85
fast_rand_printableFunction · 0.85

Calls 1

fast_randFunction · 0.85

Tested by

no test coverage detected