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

Special-case zero parameter array allocations in GetParameters #44759

Merged
merged 1 commit into from
Nov 17, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,26 @@ internal static ParameterInfo[] GetParameters(IRuntimeMethodInfo method, MemberI
{
Debug.Assert(method is RuntimeMethodInfo || method is RuntimeConstructorInfo);

return GetParameters(method, member, sig, out _, false);
return GetParameters(method, member, sig, out _, fetchReturnParameter: false);
}

internal static ParameterInfo GetReturnParameter(IRuntimeMethodInfo method, MemberInfo member, Signature sig)
{
Debug.Assert(method is RuntimeMethodInfo || method is RuntimeConstructorInfo);

ParameterInfo returnParameter;
GetParameters(method, member, sig, out returnParameter!, true);
return returnParameter;
GetParameters(method, member, sig, out ParameterInfo? returnParameter, fetchReturnParameter: true);
return returnParameter!;
}

internal static ParameterInfo[] GetParameters(
private static ParameterInfo[] GetParameters(
IRuntimeMethodInfo methodHandle, MemberInfo member, Signature sig, out ParameterInfo? returnParameter, bool fetchReturnParameter)
{
returnParameter = null;
int sigArgCount = sig.Arguments.Length;
ParameterInfo[] args = fetchReturnParameter ? null! : new ParameterInfo[sigArgCount];
ParameterInfo[] args =
fetchReturnParameter ? null! :
sigArgCount == 0 ? Array.Empty<ParameterInfo>() :
new ParameterInfo[sigArgCount];

int tkMethodDef = RuntimeMethodHandle.GetMethodDef(methodHandle);
int cParamDefs = 0;
Expand Down