Skip to content

Commit e1ad7fc

Browse files
committed
small cleanup for random utils
1 parent 01fa4a6 commit e1ad7fc

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

loader/include/Geode/utils/random.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ namespace geode::utils::random {
8282
}
8383

8484
template <typename Cont>
85-
void shuffle(Cont& vec) {
85+
void shuffle(Cont& cont) {
8686
using std::begin, std::end;
87-
shuffle(begin(vec), end(vec));
87+
shuffle(begin(cont), end(cont));
8888
}
8989

9090
GEODE_DLL std::string generateString(size_t length, std::string_view alphabet);

loader/src/utils/random.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,10 @@ void fillBytes(void* buffer, size_t size) {
7575
buf += 8;
7676
size -= 8;
7777
}
78-
79-
for (size_t i = 0; i < size; i++) {
80-
buf[i] = generate<uint8_t>();
78+
79+
if (size > 0) {
80+
uint64_t val = nextU64();
81+
std::memcpy(buf, &val, size);
8182
}
8283
}
8384

0 commit comments

Comments
 (0)