未验证 提交 3922b81f 编写于 作者: J Jan Kotas 提交者: GitHub

Delete typeof caches from CoreLib (#76126)

Caching typeof is a de-optimization with frozen runtime types
上级 aad5434f
......@@ -766,9 +766,6 @@ public CustomAttributeCtorParameter(CustomAttributeType type)
internal static unsafe class CustomAttribute
{
private static readonly RuntimeType Type_RuntimeType = (RuntimeType)typeof(RuntimeType);
private static readonly RuntimeType Type_Type = (RuntimeType)typeof(Type);
#region Internal Static Members
internal static bool IsDefined(RuntimeType type, RuntimeType? caType, bool inherit)
{
......@@ -1221,9 +1218,9 @@ internal static bool IsAttributeDefined(RuntimeModule decoratedModule, int decor
if (type is null && value is not null)
{
type = (RuntimeType)value.GetType();
if (type == Type_RuntimeType)
if (type == typeof(RuntimeType))
{
type = Type_Type;
type = (RuntimeType)typeof(Type);
}
}
......
......@@ -106,11 +106,6 @@ internal static ParameterInfo GetReturnParameter(IRuntimeMethodInfo method, Memb
}
#endregion
#region Private Statics
private static readonly Type s_DecimalConstantAttributeType = typeof(DecimalConstantAttribute);
private static readonly Type s_CustomConstantAttributeType = typeof(CustomConstantAttribute);
#endregion
#region Private Data Members
private int m_tkParamDef;
private MetadataImport m_scope;
......@@ -359,7 +354,7 @@ public override bool HasDefaultValue
{
defaultValue = GetRawDecimalConstant(attr);
}
else if (attrType!.IsSubclassOf(s_CustomConstantAttributeType))
else if (attrType!.IsSubclassOf(typeof(CustomConstantAttribute)))
{
defaultValue = GetRawConstant(attr);
}
......@@ -367,14 +362,14 @@ public override bool HasDefaultValue
}
else
{
object[] CustomAttrs = GetCustomAttributes(s_CustomConstantAttributeType, false);
object[] CustomAttrs = GetCustomAttributes(typeof(CustomConstantAttribute), false);
if (CustomAttrs.Length != 0)
{
defaultValue = ((CustomConstantAttribute)CustomAttrs[0]).Value;
}
else
{
CustomAttrs = GetCustomAttributes(s_DecimalConstantAttributeType, false);
CustomAttrs = GetCustomAttributes(typeof(DecimalConstantAttribute), false);
if (CustomAttrs.Length != 0)
{
defaultValue = ((DecimalConstantAttribute)CustomAttrs[0]).Value;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册