From 7b8f998065d49ca2b2b62eeae31f7da88eafd8bc Mon Sep 17 00:00:00 2001 From: James Date: Sun, 25 Jun 2023 14:32:54 +1200 Subject: [PATCH] perf: :zap: improve `Result` hashcode algorithm (#2201) --- Flow.Launcher.Plugin/Result.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher.Plugin/Result.cs b/Flow.Launcher.Plugin/Result.cs index ec976bdca..2fd8f500b 100644 --- a/Flow.Launcher.Plugin/Result.cs +++ b/Flow.Launcher.Plugin/Result.cs @@ -172,9 +172,16 @@ namespace Flow.Launcher.Plugin /// public override int GetHashCode() { - var hashcode = (Title?.GetHashCode() ?? 0) ^ - (SubTitle?.GetHashCode() ?? 0); - return hashcode; + unchecked + { + // 17 and 23 are prime numbers + int hashcode = 17; + hashcode = hashcode * 23 + (Title?.GetHashCode() ?? 0); + hashcode = hashcode * 23 + (SubTitle?.GetHashCode() ?? 0); + hashcode = hashcode * 23 + (AutoCompleteText?.GetHashCode() ?? 0); + hashcode = hashcode * 23 + (CopyText?.GetHashCode() ?? 0); + return hashcode; + } } ///