From 4eb9bb4e2081f2bf30c2a87d7054ad93c7de1ff4 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Wed, 8 Jan 2020 10:44:43 +0100 Subject: [PATCH] Compute disallowed result once --- src/Moniker/NameGenerator.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Moniker/NameGenerator.cs b/src/Moniker/NameGenerator.cs index d282335..c74ddf3 100644 --- a/src/Moniker/NameGenerator.cs +++ b/src/Moniker/NameGenerator.cs @@ -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; }