Skip to content

Commit

Permalink
Merge pull request #1786 from Expensify/cole_srandom
Browse files Browse the repository at this point in the history
Make SRandom::randStr() not require a reference
  • Loading branch information
tylerkaraszewski authored Jun 25, 2024
2 parents 4ce6f15 + 9ee40c7 commit f636d81
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions libstuff/SRandom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ uint64_t SRandom::rand64() {
return _distribution64(_generator);
}

string SRandom::randStr(uint& length) {
string SRandom::randStr(uint length) {
string str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
string newstr;
int pos;
while(newstr.size() != length) {
while (newstr.size() != length) {
pos = (rand64() % (str.size() - 1));
newstr += str.substr(pos,1);
newstr += str.substr(pos, 1);
}
return newstr;
}
2 changes: 1 addition & 1 deletion libstuff/SRandom.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class SRandom {
public:
static uint64_t rand64();
static uint64_t limitedRand64(uint64_t min, uint64_t max);
static string randStr(uint& length);
static string randStr(uint length);

private:
static mt19937_64 _generator;
Expand Down

0 comments on commit f636d81

Please sign in to comment.