Skip to content

Use RemoveAll to minimize list creation overhead #12006

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

Merged
merged 2 commits into from
Jun 17, 2025

Conversation

Erarndt
Copy link
Contributor

@Erarndt Erarndt commented Jun 12, 2025

Context

While this does reintroduce a capture class allocation, this is outweighed by being able to reuse the existing list since we don't need to allocate another instance as well as the internal array to hold all the items.

The savings aren't huge, but it's a pretty easy win.

Before:

image

After:

image

Looks to be a savings of ~ 6.7MB when building Roslyn.

Changes Made

Testing

Notes

Erarndt added 2 commits June 12, 2025 12:12
…rndt/removeAll

# Conflicts:
#	src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupIntrinsicTask.cs
@Copilot Copilot AI review requested due to automatic review settings June 12, 2025 19:21
Copy link
Contributor

@Copilot 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

This PR optimizes the filtering logic by replacing the manual loop that creates a new list with a RemoveAll call to reduce list allocation overhead.

  • Replaces manual filtering of ProjectItemInstance objects with a single RemoveAll call.
  • Improves performance by reusing the existing list instead of creating a new one.

Copy link
Member

@rainersigwald rainersigwald left a comment

Choose a reason for hiding this comment

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

this is outweighed by

How do you know?

(This looks ok)

@Erarndt
Copy link
Contributor Author

Erarndt commented Jun 13, 2025

this is outweighed by

How do you know?

(This looks ok)

Updated the description with some data.

@JanProvaznik JanProvaznik merged commit eb847f2 into dotnet:main Jun 17, 2025
10 checks passed
@Erarndt Erarndt deleted the dev/erarndt/removeAll branch June 18, 2025 21:59
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.

3 participants