Skip to content

Commit

Permalink
perf: Compute disallowed result once (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
atifaziz authored Aug 21, 2024
1 parent 2c94b26 commit 1e01890
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Moniker/NameGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ private static string BuildNamePair(

string result;
var (disallowedAdjective, disallowedNoun) = disallowed;
var disallowedResult = $"{disallowedAdjective}{delimiter}{disallowedNoun}";

do
{
var adjective = GetRandomEntry(adjectives);
var noun = GetRandomEntry(nouns);
result = $"{adjective}{delimiter}{noun}";
} while (result == $"{disallowedAdjective}{delimiter}{disallowedNoun}");
} while (result == disallowedResult);

return result;
}
Expand Down

0 comments on commit 1e01890

Please sign in to comment.