未验证 提交 cc4d26d5 编写于 作者: S Stephen Toub 提交者: GitHub

Avoid empty array allocation in MethodBase.GetParameterTypes (#67149)

No parameters is very common.  Avoid a `new Type[0]` array in such cases.
上级 0c0c7c6e
......@@ -55,6 +55,10 @@ public abstract partial class MethodBase : MemberInfo
internal virtual Type[] GetParameterTypes()
{
ParameterInfo[] paramInfo = GetParametersNoCopy();
if (paramInfo.Length == 0)
{
return Type.EmptyTypes;
}
Type[] parameterTypes = new Type[paramInfo.Length];
for (int i = 0; i < paramInfo.Length; i++)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册