Skip to content

Commit a995c8c

Browse files
authored
CacheKey uses only UserAgent for Equals and GetHashCode (#11)
1 parent 30a7553 commit a995c8c

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

Diff for: src/MyCSharp.HttpUserAgentParser.MemoryCache/HttpUserAgentParserMemoryCachedProvider.cs

+3-13
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,10 @@ private CacheKey GetKey(string userAgent)
5050

5151
public HttpUserAgentParserMemoryCachedProviderOptions Options { get; set; } = null!;
5252

53-
public bool Equals(CacheKey? other)
54-
{
55-
if (ReferenceEquals(this, other)) return true;
56-
if (other is null) return false;
57-
58-
return this.UserAgent == other.UserAgent && this.Options == other.Options;
59-
}
60-
61-
public override bool Equals(object? obj)
62-
{
63-
return this.Equals(obj as CacheKey);
64-
}
53+
public bool Equals(CacheKey? other) => this.UserAgent == other?.UserAgent;
54+
public override bool Equals(object? obj) => this.Equals(obj as CacheKey);
6555

66-
public override int GetHashCode() => HashCode.Combine(this.UserAgent, this.Options);
56+
public override int GetHashCode() => this.UserAgent.GetHashCode();
6757
}
6858
}
6959
}

0 commit comments

Comments
 (0)