Skip to content

Commit

Permalink
Memory optimization from #919: Autofac.Features.OpenGenerics.OpenGene…
Browse files Browse the repository at this point in the history
…ricDecoratorRegistrationSource.
  • Loading branch information
tillig committed Aug 16, 2018
1 parent fc17758 commit 1738b76
Showing 1 changed file with 9 additions and 2 deletions.
Expand Up @@ -77,13 +77,20 @@ public IEnumerable<IComponentRegistration> RegistrationsFor(Service service, Fun
return Enumerable.Empty<IComponentRegistration>();
}

private static IEnumerable<Parameter> AddDecoratedComponentParameter(Type decoratedParameterType, IComponentRegistration decoratedComponent, IEnumerable<Parameter> configuredParameters)
private static Parameter[] AddDecoratedComponentParameter(Type decoratedParameterType, IComponentRegistration decoratedComponent, IList<Parameter> configuredParameters)
{
var parameter = new ResolvedParameter(
(pi, c) => pi.ParameterType == decoratedParameterType,
(pi, c) => c.ResolveComponent(decoratedComponent, Enumerable.Empty<Parameter>()));

return new[] { parameter }.Concat(configuredParameters);
var resultArray = new Parameter[configuredParameters.Count + 1];
resultArray[0] = parameter;
for (int i = 0; i < configuredParameters.Count; i++)
{
resultArray[i + 1] = configuredParameters[i];
}

return resultArray;
}

public bool IsAdapterForIndividualComponents => true;
Expand Down

0 comments on commit 1738b76

Please sign in to comment.