Remove System.Linq dependency from System.Security.Cryptography.X509Certificates
authorStephen Toub <stoub@microsoft.com>
Tue, 8 Oct 2019 16:57:21 +0000 (12:57 -0400)
committerJeremy Barton <jbarton@microsoft.com>
Tue, 8 Oct 2019 16:57:21 +0000 (09:57 -0700)
commit4389df6728661d8feb127e211e7375305e313e85
tree8ab66d0881467f109cfeefd61b7867ab92f769ff
parentab3f09587f51022f40bff940df34035e7f05b871
Remove System.Linq dependency from System.Security.Cryptography.X509Certificates

System.Linq was only being used in two places:
- In Pkcs10CertificateRequestInfo, it was using Collection<>.Select(...).ToArray().  We can replace it with a simple for loop, which is both faster (e.g. fewer delegate invocations) and fewer generic instantiations (no one else is going to have an instantiation with AttributeAsn).
- In LoadMachineStores on Linux, it was using Prepend.  We can avoid the need for Prepend (and the associated allocations) entirely by slightly reorganizing the method and using a local function.

Commit migrated from https://github.com/dotnet/corefx/commit/5ad15fcb189a9c232051d03c1e889f985f62232b
src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/CachedSystemStoreProvider.cs
src/libraries/System.Security.Cryptography.X509Certificates/src/System.Security.Cryptography.X509Certificates.csproj
src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/Pkcs10CertificationRequestInfo.cs