Skip to content

Commit 1936acd

Browse files
committed
使用字段缓存hashCode
1 parent f962484 commit 1936acd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

WebApiClientCore.Extensions.OAuths/TokenProviderFactory.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ private ITokenProvider GetTokenProviderFromBaseType(Type httpApiType)
9191
/// </summary>
9292
private class CacheKey : IEquatable<CacheKey>
9393
{
94+
private readonly int hashCode;
95+
9496
public Type HttpApiType { get; }
9597

9698
public TypeMatchMode TypeMatchMode { get; }
@@ -99,6 +101,7 @@ public CacheKey(Type httpApiType, TypeMatchMode typeMatchMode)
99101
{
100102
this.HttpApiType = httpApiType;
101103
this.TypeMatchMode = typeMatchMode;
104+
this.hashCode = HashCode.Combine(this.HttpApiType, this.TypeMatchMode);
102105
}
103106

104107
public bool Equals(CacheKey other)
@@ -113,7 +116,7 @@ public override bool Equals(object obj)
113116

114117
public override int GetHashCode()
115118
{
116-
return HashCode.Combine(this.HttpApiType, this.TypeMatchMode);
119+
return this.hashCode;
117120
}
118121
}
119122
}

0 commit comments

Comments
 (0)