From 1e018906495de9f76cb1d32de32064ecfc27f468 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Wed, 21 Aug 2024 16:56:09 +0200 Subject: [PATCH] perf: Compute disallowed result once (#5) --- 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; }