| 127 | } |
| 128 | |
| 129 | void 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 | |
| 146 | uint64_t DeterministicRandom::peek() const { |
| 147 | return next; |
no test coverage detected