Skip to content

Improve DSC expression grammar speed#1552

Open
SteveL-MSFT wants to merge 1 commit into
PowerShell:mainfrom
SteveL-MSFT:expression-grammar
Open

Improve DSC expression grammar speed#1552
SteveL-MSFT wants to merge 1 commit into
PowerShell:mainfrom
SteveL-MSFT:expression-grammar

Conversation

@SteveL-MSFT
Copy link
Copy Markdown
Member

PR Summary

Small improvement to DSC expression parsing speed.

Before change: average speed: 3147 bytes/ms

After change: average speed: 3233 bytes/ms

Copilot AI review requested due to automatic review settings May 30, 2026 18:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Small performance optimization to the tree-sitter grammar for DSC expressions. Makes regex patterns greedy (longest-match) since tree-sitter's lexer already prefers longest-match, removes redundant alternations, and inlines several helper rules to reduce parse tree overhead.

Changes:

  • Added an inline declaration for _booleanLiteral, _argument, _quotedString, and _expressionString so they are expanded at compile time.
  • Simplified regexes for escapedStringLiteral and stringLiteral to greedy patterns (/.*/ and /[^\[][\s\S]*/).
  • Removed the redundant |\n branch in the string regex (already covered by [^']).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants