Skip to content

Commit 9e81bcf

Browse files
committed
Optimize IsClosure()
1 parent ff09540 commit 9e81bcf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Orm/Xtensive.Orm/Reflection/TypeHelper.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1188,9 +1188,11 @@ public static bool IsAnonymous(this Type type)
11881188
/// </returns>
11891189
public static bool IsClosure(this Type type)
11901190
{
1191+
if (type.BaseType != WellKnownTypes.Object) {
1192+
return false;
1193+
}
11911194
var typeName = type.Name;
1192-
return type.BaseType == WellKnownTypes.Object
1193-
&& (typeName.StartsWith("<>", StringComparison.Ordinal) || typeName.StartsWith("VB$", StringComparison.Ordinal))
1195+
return (typeName.StartsWith("<>", StringComparison.Ordinal) || typeName.StartsWith("VB$", StringComparison.Ordinal))
11941196
&& typeName.IndexOf("DisplayClass", StringComparison.Ordinal) >= 0
11951197
&& type.IsDefined(CompilerGeneratedAttributeType, false);
11961198
}

0 commit comments

Comments
 (0)