Skip to content

Commit 7b8f998

Browse files
authored
perf: ⚡ improve Result hashcode algorithm (#2201)
1 parent cdff8fc commit 7b8f998

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Flow.Launcher.Plugin/Result.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,16 @@ public override bool Equals(object obj)
172172
/// <inheritdoc />
173173
public override int GetHashCode()
174174
{
175-
var hashcode = (Title?.GetHashCode() ?? 0) ^
176-
(SubTitle?.GetHashCode() ?? 0);
177-
return hashcode;
175+
unchecked
176+
{
177+
// 17 and 23 are prime numbers
178+
int hashcode = 17;
179+
hashcode = hashcode * 23 + (Title?.GetHashCode() ?? 0);
180+
hashcode = hashcode * 23 + (SubTitle?.GetHashCode() ?? 0);
181+
hashcode = hashcode * 23 + (AutoCompleteText?.GetHashCode() ?? 0);
182+
hashcode = hashcode * 23 + (CopyText?.GetHashCode() ?? 0);
183+
return hashcode;
184+
}
178185
}
179186

180187
/// <inheritdoc />

0 commit comments

Comments
 (0)