From 71d85f92bb185fa81aa775b947614a98524a87fd Mon Sep 17 00:00:00 2001 From: brawlee Date: Tue, 21 Nov 2023 16:29:31 +0530 Subject: [PATCH] refactor: Use `Helper::setElement()` Use helper function instead of rewriting code --- src/modules/string/String.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/modules/string/String.cpp b/src/modules/string/String.cpp index d80fff49..4a118e00 100644 --- a/src/modules/string/String.cpp +++ b/src/modules/string/String.cpp @@ -186,8 +186,7 @@ std::string String::binary(GuaranteeMap&& guarantee, unsigned int length) while (true) { // pick random char from targetCharacters - std::mt19937 gen(std::random_device{}()); - std::sample(targetCharacters.begin(), targetCharacters.end(), &generatedChar, 1, gen); + generatedChar = Helper::setElement(targetCharacters); auto it = guarantee.find(generatedChar); // if no constraint on generated char, break out of loop