Repository navigation
Index hashtable brace positions in token operations - #2299
Kire (kireadmin) wants to merge 1 commit into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Kire (@kireadmin) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
3 similar comments
|
Kire (@kireadmin) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
|
Kire (@kireadmin) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
|
Kire (@kireadmin) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
🟡 Changes recommended
The brace-pairing test never exercises hashtable filtering and still passes if that filtering is removed, leaving the intended regression undetected.
1 open issue
What changed in this PR
This PR optimizes brace pairing in the analyzer’s token operations by indexing hashtable closing-brace offsets instead of repeatedly scanning hashtable ASTs.
Changes:
- Replace per-brace scans with hash-set membership checks.
- Add a test for script-block brace pairing in a script containing a hashtable.
| File | Description |
|---|---|
| Tests/Engine/TokenOperations.tests.ps1 | Adds assertions for script-block brace pairing alongside a hashtable. |
| Engine/TokenOperations.cs | Indexes hashtable end offsets for constant-time closing-brace checks. |
Review effort: Balanced
| $scriptText = @' | ||
| $h = @{ key = 72 } | ||
| if ($true) { | ||
| 'value' |

PR Summary
Index hashtable closing-brace offsets once before scanning tokens, replacing a full hashtable scan for every closing brace with constant-time membership checks. Add a regression test confirming script-block brace pairing remains correct in a script containing a hashtable.
Validation
dotnet build Engine/Engine.csproj --no-restore --framework net8 --configuration PSV7Debug— passed (0 warnings, 0 errors).PR Checklist
.cs,.ps1and.psm1files have the correct copyright headerWIP:to the title and remove the prefix when it is ready.