From 8ffc0b3f51610656edaa6297f00619385f371e40 Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Wed, 30 Sep 2020 18:09:46 +0300 Subject: [PATCH] Optimize Type.IsPrimitive (#42891) --- .../src/System.Private.CoreLib/src/System/RuntimeHandles.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/RuntimeHandles.cs b/src/coreclr/src/System.Private.CoreLib/src/System/RuntimeHandles.cs index 965df43cfaf31..adc808e43de5a 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/RuntimeHandles.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/RuntimeHandles.cs @@ -126,10 +126,7 @@ internal static bool IsTypeDefinition(RuntimeType type) internal static bool IsPrimitive(RuntimeType type) { - CorElementType corElemType = GetCorElementType(type); - return (corElemType >= CorElementType.ELEMENT_TYPE_BOOLEAN && corElemType <= CorElementType.ELEMENT_TYPE_R8) || - corElemType == CorElementType.ELEMENT_TYPE_I || - corElemType == CorElementType.ELEMENT_TYPE_U; + return RuntimeHelpers.IsPrimitiveType(GetCorElementType(type)); } internal static bool IsByRef(RuntimeType type)