Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance Improvement - IsGenericTypeDefinedBy #1038

Merged
merged 1 commit into from
Nov 3, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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