Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new GetProjectDirectory method to reduce string allocations #9603

Merged
merged 2 commits into from
Dec 2, 2024

Conversation

drewnoakes
Copy link
Member

@drewnoakes drewnoakes commented Nov 27, 2024

Avoids calling Path.GetDirectoryName in a bunch of places, which will allocate a new string for each call. The new extension method in CPS provides a singleton string for the project.

Needs https://dev.azure.com/devdiv/DevDiv/_git/VS/pullrequest/595076 or newer to insert before being merged.

Microsoft Reviewers: Open in CodeFlow

@drewnoakes drewnoakes added Tenet-Performance This issue affects the "Performance" tenet. Performance-Scenario-Solution-Open This issue affects solution open performance. Performance-Scenario-General This issue affects performance in general. labels Nov 27, 2024
@drewnoakes
Copy link
Member Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@drewnoakes
Copy link
Member Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@drewnoakes
Copy link
Member Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@drewnoakes
Copy link
Member Author

Needs https://dev.azure.com/devdiv/DevDiv/_git/VS/pullrequest/595076 or newer to insert before being merged.

That insertion has now completed.

@drewnoakes drewnoakes marked this pull request as ready for review November 28, 2024 00:41
@drewnoakes drewnoakes requested a review from a team as a code owner November 28, 2024 00:41
@drewnoakes drewnoakes force-pushed the project-dir-allocations branch from a9397bf to 10f917a Compare November 28, 2024 01:07
@drewnoakes drewnoakes force-pushed the project-dir-allocations branch from 9063c6a to 12377af Compare November 28, 2024 23:06
Copy link
Contributor

@haileymck haileymck left a comment

Choose a reason for hiding this comment

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

Nice change!

@@ -894,7 +894,7 @@ internal async Task<string> GetLaunchSettingsFilePathNoCacheAsync()
// see: https://github.com/dotnet/project-system/issues/2316.

// Default to the project directory if we're not able to get the AppDesigner folder.
string folder = Path.GetDirectoryName(_commonProjectServices.Project.FullPath);
string folder = _commonProjectServices.Project.GetProjectDirectory();
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the new GetProjectDirectory() from CPS works cross-platform?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it's in the host-agnostic layer so is available outside of VS too.

The CPS PRs were:

@drewnoakes drewnoakes merged commit 3cd353a into dotnet:main Dec 2, 2024
5 checks passed
@drewnoakes drewnoakes deleted the project-dir-allocations branch December 2, 2024 21:42
@dotnet-policy-service dotnet-policy-service bot added this to the 17.12 milestone Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Performance-Scenario-General This issue affects performance in general. Performance-Scenario-Solution-Open This issue affects solution open performance. Tenet-Performance This issue affects the "Performance" tenet.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants