MCPcopy Create free account
hub / github.com/apple/foundationdb / randomBytes

Method randomBytes

flow/DeterministicRandom.cpp:129–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127}
128
129void DeterministicRandom::randomBytes(uint8_t* buf, int length) {
130 constexpr const int unitLen = sizeof(decltype(gen64()));
131 for (int i = 0; i < length; i += unitLen) {
132 auto val = gen64();
133 memcpy(buf + i, &val, std::min(unitLen, length - i));
134 }
135 if (randLog && useRandLog) {
136 constexpr const int cutOff = 32;
137 bool tooLong = length > cutOff;
138 fmt::print(randLog,
139 "Rbytes[{}] {}{}\n",
140 length,
141 StringRef(buf, std::min(cutOff, length)).printable(),
142 tooLong ? "..." : "");
143 }
144}
145
146uint64_t DeterministicRandom::peek() const {
147 return next;

Calls 4

memcpyFunction · 0.85
printFunction · 0.50
StringRefClass · 0.50
printableMethod · 0.45

Tested by

no test coverage detected