[repo-assist] perf: hoist regex literals in C# ERROR-node heuristics to module scope - #555
Draft
github-actions[bot] wants to merge 1 commit into
Conversation
The ERROR-node and malformed-declaration complexity heuristics in csharpAnalyzer.ts (getComplexityFromErrorNode, getComplexityFromMalformedDeclaration, and their corresponding *Reason variants) used inline regex literals that were recompiled on every invocation. These heuristics can run multiple times per file when preprocessor directives split method bodies across ERROR nodes. Hoisted all regex literals used by these functions to module-level const declarations, matching the "hoist to module scope" pattern already used elsewhere in the codebase (e.g. codeLensProvider.ts's excludeRegexCache). No behavioral change: same patterns, same test order/short-circuiting. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
🤖 This is an automated pull request from Repo Assist, an AI assistant. See .github/workflows/repo-assist.md for details.
What
The C# preprocessor ERROR-node/malformed-declaration complexity heuristics (getComplexityFromErrorNode, getComplexityFromMalformedDeclaration, and their *Reason counterparts in csharpAnalyzer.ts) used inline regex literals that get recompiled on every call. These heuristics run whenever tree-sitter cannot parse a method body cleanly due to preprocessor directives (#if/#else), which can happen multiple times per file in preprocessor-heavy C# code.
This PR hoists all of those regex literals to module-level const declarations (e.g. IF_KEYWORD_REGEX, LOGICAL_OPERATOR_GLOBAL_REGEX, TERNARY_OPERATOR_REGEX), avoiding repeated regex compilation on each invocation - the same "hoist to module scope" pattern already used elsewhere in this codebase (see codeLensProvider.ts's excludeRegexCache).
Why this is safe
Test Status
Proactive Task 5 (Coding Improvements) PR, complementing the companion perf PR for node.children allocation avoidance from the same run.
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
releaseassets.githubusercontent.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.
Add this agentic workflow to your repo
To install this agentic workflow, run