From 1738b769f617bfa0ce2bda1de14d01df2bd9f4b5 Mon Sep 17 00:00:00 2001 From: Travis Illig Date: Thu, 16 Aug 2018 08:30:14 -0700 Subject: [PATCH] Memory optimization from #919: Autofac.Features.OpenGenerics.OpenGenericDecoratorRegistrationSource. --- .../OpenGenericDecoratorRegistrationSource.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Autofac/Features/OpenGenerics/OpenGenericDecoratorRegistrationSource.cs b/src/Autofac/Features/OpenGenerics/OpenGenericDecoratorRegistrationSource.cs index 6e0d6e44c..3a3c027be 100644 --- a/src/Autofac/Features/OpenGenerics/OpenGenericDecoratorRegistrationSource.cs +++ b/src/Autofac/Features/OpenGenerics/OpenGenericDecoratorRegistrationSource.cs @@ -77,13 +77,20 @@ public IEnumerable RegistrationsFor(Service service, Fun return Enumerable.Empty(); } - private static IEnumerable AddDecoratedComponentParameter(Type decoratedParameterType, IComponentRegistration decoratedComponent, IEnumerable configuredParameters) + private static Parameter[] AddDecoratedComponentParameter(Type decoratedParameterType, IComponentRegistration decoratedComponent, IList configuredParameters) { var parameter = new ResolvedParameter( (pi, c) => pi.ParameterType == decoratedParameterType, (pi, c) => c.ResolveComponent(decoratedComponent, Enumerable.Empty())); - 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;