From cdff8fcd7ce17321fe53c089717d5364f678da6d Mon Sep 17 00:00:00 2001 From: James Date: Sun, 25 Jun 2023 01:46:27 +1200 Subject: [PATCH 1/3] fix: :bug: check autocomplete and copy text for `Result` equality (#2201) --- Flow.Launcher.Plugin/Result.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Flow.Launcher.Plugin/Result.cs b/Flow.Launcher.Plugin/Result.cs index 1c4467762d5..ec976bdcab1 100644 --- a/Flow.Launcher.Plugin/Result.cs +++ b/Flow.Launcher.Plugin/Result.cs @@ -161,6 +161,8 @@ public override bool Equals(object obj) var equality = string.Equals(r?.Title, Title) && string.Equals(r?.SubTitle, SubTitle) && + string.Equals(r?.AutoCompleteText, AutoCompleteText) && + string.Equals(r?.CopyText, CopyText) && string.Equals(r?.IcoPath, IcoPath) && TitleHighlightData == r.TitleHighlightData; From 7b8f998065d49ca2b2b62eeae31f7da88eafd8bc Mon Sep 17 00:00:00 2001 From: James Date: Sun, 25 Jun 2023 14:32:54 +1200 Subject: [PATCH 2/3] 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 ec976bdcab1..2fd8f500b06 100644 --- a/Flow.Launcher.Plugin/Result.cs +++ b/Flow.Launcher.Plugin/Result.cs @@ -172,9 +172,16 @@ public override bool Equals(object obj) /// 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; + } } /// From 5dd0d349de50ce1bfa925d317d3e4494eb891bbf Mon Sep 17 00:00:00 2001 From: James Date: Mon, 26 Jun 2023 13:51:37 +1200 Subject: [PATCH 3/3] refactor: :recycle: use `HashCode.Combine` for `Result` hashcode (#2201) --- Flow.Launcher.Plugin/Result.cs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Flow.Launcher.Plugin/Result.cs b/Flow.Launcher.Plugin/Result.cs index 2fd8f500b06..7e444666253 100644 --- a/Flow.Launcher.Plugin/Result.cs +++ b/Flow.Launcher.Plugin/Result.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime; using System.Collections.Generic; using System.IO; using System.Threading.Tasks; @@ -172,16 +173,7 @@ public override bool Equals(object obj) /// public override int GetHashCode() { - 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; - } + return HashCode.Combine(Title, SubTitle, AutoCompleteText, CopyText, IcoPath); } ///