Merge pull request #7353 from davkean/RemoveUnneededAllocations

Remove unneeded char[] allocations
This commit is contained in:
William Lee 2017-08-02 14:07:30 -07:00 committed by GitHub
commit fffe3142ad

View file

@ -11,6 +11,8 @@ namespace Microsoft.DotNet.Cli.Utils
{ {
public class EnvironmentProvider : IEnvironmentProvider public class EnvironmentProvider : IEnvironmentProvider
{ {
private static char[] s_pathSeparator = new char[] { Path.PathSeparator };
private static char[] s_quote = new char[] { '"' };
private IEnumerable<string> _searchPaths; private IEnumerable<string> _searchPaths;
private IEnumerable<string> _executableExtensions; private IEnumerable<string> _executableExtensions;
@ -42,8 +44,8 @@ namespace Microsoft.DotNet.Cli.Utils
searchPaths.AddRange(Environment searchPaths.AddRange(Environment
.GetEnvironmentVariable("PATH") .GetEnvironmentVariable("PATH")
.Split(Path.PathSeparator) .Split(s_pathSeparator)
.Select(p => p.Trim('"'))); .Select(p => p.Trim(s_quote)));
_searchPaths = searchPaths; _searchPaths = searchPaths;
} }