perf: improve Result hashcode algorithm (#2201)

This commit is contained in:
James 2023-06-25 14:32:54 +12:00 committed by GitHub
parent cdff8fcd7c
commit 7b8f998065
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -172,9 +172,16 @@ namespace Flow.Launcher.Plugin
/// <inheritdoc />
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;
}
}
/// <inheritdoc />