Skip to content

Avoid array allocations in CorePsAssemblyLoadContext - #14291

Merged
Dongbo Wang (daxian-dbw) merged 1 commit into
PowerShell:masterfrom
xtqqczze:linq-PowerShellAssemblyLoadContext2
Dec 3, 2020
Merged

Avoid array allocations in CorePsAssemblyLoadContext#14291
Dongbo Wang (daxian-dbw) merged 1 commit into
PowerShell:masterfrom
xtqqczze:linq-PowerShellAssemblyLoadContext2

Conversation

@xtqqczze

@xtqqczze xtqqczze commented Nov 30, 2020

Copy link
Copy Markdown
Contributor

PR Summary

Avoid IEnumerable<string> -> ToArray -> IEnumerable<string> round-trip.

  • Replace GetDirectories with EnumerateDirectories
  • Replace GetFiles with EnumerateFiles

PR Context

I considered removing the Linq methods from the class, but GetDirectories and GetFiles are implemented using Linq ToArray and an internal method IEnumerable<string> InternalEnumeratePaths, so we have to load the Linq assembly anyway.

Contributes to #14318.

PR Checklist

@daxian-dbw

Copy link
Copy Markdown
Member

xtqqczze I'm afraid you need to rebase to fix the markdown URL check failure. It was fixed by #14297

@xtqqczze
xtqqczze force-pushed the linq-PowerShellAssemblyLoadContext2 branch from 9f21d12 to ff4129b Compare December 2, 2020 09:48
@xtqqczze
xtqqczze marked this pull request as ready for review December 2, 2020 09:49

@daxian-dbw Dongbo Wang (daxian-dbw) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The change would avoid the unnecessary ToArray() call in GetDirectories.

@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit d47864d into PowerShell:master Dec 3, 2020
@daxian-dbw Dongbo Wang (daxian-dbw) added the CL-Performance Indicates that a PR should be marked as a performance improvement in the Change Log label Dec 3, 2020
@xtqqczze
xtqqczze deleted the linq-PowerShellAssemblyLoadContext2 branch December 4, 2020 09:16
@xtqqczze

xtqqczze commented Dec 4, 2020

Copy link
Copy Markdown
Contributor Author

Submitted #14317 for similar changes in TestModuleManifestCommand.

@ghost

Copy link
Copy Markdown

🎉v7.2.0-preview.2 has been released which incorporates this pull request.:tada:

Handy links:

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj/PowerShell that referenced this pull request Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Performance Indicates that a PR should be marked as a performance improvement in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants