refactor: make GetRand a template, remove GetRandInt

This commit is contained in:
pasta
2022-01-31 19:32:59 +07:00
parent 505ba39665
commit ab1ea29ba1
12 changed files with 34 additions and 31 deletions

View File

@@ -49,8 +49,7 @@ template <typename Data>
bool SerializeFileDB(const std::string& prefix, const fs::path& path, const Data& data, int version)
{
// Generate random temporary filename
uint16_t randv = 0;
GetRandBytes({(unsigned char*)&randv, sizeof(randv)});
const uint16_t randv{GetRand<uint16_t>()};
std::string tmpfn = strprintf("%s.%04x", prefix, randv);
// open temp output file, and associate with CAutoFile