Skip to content

Commit

Permalink
Change IsGenericTypeDefinedByCache to use ValueTuple for key rather t…
Browse files Browse the repository at this point in the history
…han Tuple. Performance gain.
  • Loading branch information
alistairjevans authored and alexmg committed Nov 3, 2019
1 parent 5a74ca8 commit 5364c97
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Autofac/Util/TypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ internal static class TypeExtensions

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

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

public static Type FunctionReturnType(this Type type)
{
Expand Down Expand Up @@ -148,7 +148,7 @@ public static bool IsGenericListOrCollectionInterfaceType(this Type type)
public static bool IsGenericTypeDefinedBy(this Type @this, Type openGeneric)
{
return IsGenericTypeDefinedByCache.GetOrAdd(
Tuple.Create(@this, openGeneric),
(@this, openGeneric),
key => !key.Item1.GetTypeInfo().ContainsGenericParameters
&& key.Item1.GetTypeInfo().IsGenericType
&& key.Item1.GetGenericTypeDefinition() == key.Item2);
Expand Down

0 comments on commit 5364c97

Please sign in to comment.