From 2249f1eceeaac14abeca441f171866b24645bd57 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 298872b..4dc7298 100644 --- a/src/Moniker/NameGenerator.cs +++ b/src/Moniker/NameGenerator.cs @@ -65,12 +65,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; }