Repository navigation
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
Every removal path initializes the dictionary before use, and the guarded loop preserves existing behavior.
No open issues 🎉
What changed in this PR
Reduces allocations during PowerShell command lookup without changing path resolution.
Changes:
- Allocates the removal-index dictionary only when a path needs removal.
- Skips the removal loop when no dictionary was allocated.
| File | Description |
|---|---|
| src/System.Management.Automation/engine/CommandPathSearch.cs | Lazily initializes removal tracking and guards its use. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
Allocate the command-path removal index only when relative lookup paths actually require removal.
PR Context
CommandPathSearch.ResolveCurrentDirectoryInLookupPathsran for every command-path search and eagerly created aSortedDictionary, even when the PATH entries were absolute and no paths needed removal. Make the allocation lazy so the common no-removal path avoids that object and its internal storage, without changing path resolution.PR Checklist
PR has a meaningful title
Summarized changes
Make sure all
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header (no new files)This PR is ready to merge. This is not a work in progress.
Breaking changes
User-facing changes
Testing - New and feature
Validation:
dotnet build src\System.Management.Automation\System.Management.Automation.csproj -c Release -f net11.0 -p:PublishReadyToRun=false --nologo— passed, 0 warnings/errors.Start-PSBuild -NoPSModuleRestore -Configuration Debug -SkipExperimentalFeatureGenerationwith$env:PublishReadyToRun = 'false'— passed.Start-PSPester -Path .\test\powershell\engine\Basic\CommandDiscovery.Tests.ps1 -BinDir .\src\powershell-win-core\bin\Debug\net11.0\win7-x64\publish -Tag CI -Quiet -ThrowOnFailure -SkipTestToolBuild— passed, 37 tests, 0 failures, 2 inconclusive.