@@ -17,36 +17,30 @@ public class ProxyCacheEntry : IEquatable<ProxyCacheEntry>
17
17
18
18
public ProxyCacheEntry ( System . Type baseType , System . Type [ ] interfaces )
19
19
{
20
- if ( baseType == null )
21
- throw new ArgumentNullException ( nameof ( baseType ) ) ;
22
- BaseType = baseType ;
23
- _uniqueInterfaces = new HashSet < System . Type > ( interfaces ?? new System . Type [ 0 ] ) ;
20
+ BaseType = baseType ?? throw new ArgumentNullException ( nameof ( baseType ) ) ;
24
21
25
- if ( _uniqueInterfaces . Count == 0 )
26
- {
27
- _hashCode = baseType . GetHashCode ( ) ;
28
- return ;
29
- }
30
-
31
- var allTypes = new List < System . Type > ( _uniqueInterfaces ) { baseType } ;
32
- _hashCode = 59 ;
33
- foreach ( System . Type type in allTypes )
22
+ var uniqueInterfaces = new HashSet < System . Type > ( ) ;
23
+ if ( interfaces != null && interfaces . Length != 0 )
24
+ uniqueInterfaces . UnionWith ( interfaces ) ;
25
+ _uniqueInterfaces = uniqueInterfaces ;
26
+
27
+ _hashCode = 59 ^ baseType . GetHashCode ( ) ;
28
+ // This simple implementation is nonsensitive to list order. If changing it for a sensitive one,
29
+ // take care of ordering the list.
30
+ foreach ( var type in _uniqueInterfaces )
34
31
{
35
- // This simple implementation is nonsensitive to list order. If changing it for a sensitive one,
36
- // take care of ordering the list.
37
32
_hashCode ^= type . GetHashCode ( ) ;
38
33
}
39
34
}
40
35
41
36
public System . Type BaseType { get ; }
42
- public IReadOnlyCollection < System . Type > Interfaces { get { return _uniqueInterfaces ; } }
43
-
44
- private HashSet < System . Type > _uniqueInterfaces ;
37
+ public IReadOnlyCollection < System . Type > Interfaces => _uniqueInterfaces ;
38
+
39
+ private readonly HashSet < System . Type > _uniqueInterfaces ;
45
40
46
41
public override bool Equals ( object obj )
47
42
{
48
- var that = obj as ProxyCacheEntry ;
49
- return Equals ( that ) ;
43
+ return Equals ( obj as ProxyCacheEntry ) ;
50
44
}
51
45
52
46
public bool Equals ( ProxyCacheEntry other )
@@ -64,4 +58,4 @@ public bool Equals(ProxyCacheEntry other)
64
58
65
59
public override int GetHashCode ( ) => _hashCode ;
66
60
}
67
- }
61
+ }
0 commit comments