Skip to content

Commit 5364c97

Browse files
alistairjevansalexmg
authored andcommitted
Change IsGenericTypeDefinedByCache to use ValueTuple for key rather than Tuple. Performance gain.
1 parent 5a74ca8 commit 5364c97

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Autofac/Util/TypeExtensions.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ internal static class TypeExtensions
3939

4040
private static readonly ConcurrentDictionary<Type, bool> IsGenericListOrCollectionInterfaceTypeCache = new ConcurrentDictionary<Type, bool>();
4141

42-
private static readonly ConcurrentDictionary<Tuple<Type, Type>, bool> IsGenericTypeDefinedByCache = new ConcurrentDictionary<Tuple<Type, Type>, bool>();
42+
private static readonly ConcurrentDictionary<(Type, Type), bool> IsGenericTypeDefinedByCache = new ConcurrentDictionary<(Type, Type), bool>();
4343

4444
public static Type FunctionReturnType(this Type type)
4545
{
@@ -148,7 +148,7 @@ public static bool IsGenericListOrCollectionInterfaceType(this Type type)
148148
public static bool IsGenericTypeDefinedBy(this Type @this, Type openGeneric)
149149
{
150150
return IsGenericTypeDefinedByCache.GetOrAdd(
151-
Tuple.Create(@this, openGeneric),
151+
(@this, openGeneric),
152152
key => !key.Item1.GetTypeInfo().ContainsGenericParameters
153153
&& key.Item1.GetTypeInfo().IsGenericType
154154
&& key.Item1.GetGenericTypeDefinition() == key.Item2);

0 commit comments

Comments
 (0)