From bf58a5a060c9c80e416b47040ce22b900f32bd2c Mon Sep 17 00:00:00 2001 From: David Kean Date: Wed, 2 Aug 2017 18:59:45 +1000 Subject: [PATCH] Remove unneeded char[] allocations This was causing 0.2% of allocations in a design-time build trace from a customer. --- src/Microsoft.DotNet.Cli.Utils/EnvironmentProvider.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.DotNet.Cli.Utils/EnvironmentProvider.cs b/src/Microsoft.DotNet.Cli.Utils/EnvironmentProvider.cs index 6c23d4c9e..65db78e82 100644 --- a/src/Microsoft.DotNet.Cli.Utils/EnvironmentProvider.cs +++ b/src/Microsoft.DotNet.Cli.Utils/EnvironmentProvider.cs @@ -11,6 +11,8 @@ namespace Microsoft.DotNet.Cli.Utils { public class EnvironmentProvider : IEnvironmentProvider { + private static char[] s_pathSeparator = new char[] { Path.PathSeparator }; + private static char[] s_quote = new char[] { '"' }; private IEnumerable _searchPaths; private IEnumerable _executableExtensions; @@ -42,8 +44,8 @@ namespace Microsoft.DotNet.Cli.Utils searchPaths.AddRange(Environment .GetEnvironmentVariable("PATH") - .Split(Path.PathSeparator) - .Select(p => p.Trim('"'))); + .Split(s_pathSeparator) + .Select(p => p.Trim(s_quote))); _searchPaths = searchPaths; }