Skip to content

Avoid allocations when checking project reference declaration directories - #63977

Open
auvred wants to merge 1 commit into
microsoft:mainfrom
auvred:perf-project-reference-dts-directory-check
Open

Avoid allocations when checking project reference declaration directories#63977
auvred wants to merge 1 commit into
microsoft:mainfrom
auvred:perf-project-reference-dts-directory-check

Conversation

@auvred

@auvred auvred commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #63976

ContainsPath does the same check without extra allocations

// ContainsPath checks whether child is contained within or equal to p.
// Since Path values are already rooted, reduced, and case-canonicalized,
// this is a simple string prefix check.
func (p Path) ContainsPath(child Path) bool {
if len(p) == 0 {
return false
}
return p == child || len(child) > len(p) && strings.HasPrefix(string(child), string(p)) && (p[len(p)-1] == '/' || child[len(p)] == '/')
}


Before: handled method 'textDocument/references' (32) in 3.071585458s

image

After: handled method 'textDocument/references' (20) in 2.692099625s

image

Copilot AI balanced review requested due to automatic review settings August 24, 2026 06:39
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Aug 24, 2026
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Aug 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Replaces allocation-heavy path concatenation with Path.ContainsPath when checking project-reference declaration directories.

Changes:

  • Uses canonical path containment checks in both directions.
  • Avoids ephemeral string allocations in a language-server hot path.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

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

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

Excessive string allocations in projectReferenceDtsFakingVfs

2 participants