Skip to content

Lookup.ExplicitModifications switch to concrete dictionary type for enumerator. #11985

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ttstanley
Copy link
Contributor

@ttstanley ttstanley commented Jun 10, 2025

Context

When building a smaller solution we can see the boxing to IEnumerator pop up for 0.1% allocations
image

Changes Made

Switched from returning IEnumerator to the underlying dictionary type to allow usage of the struct enumerator to prevent boxing.

@ttstanley ttstanley marked this pull request as ready for review June 25, 2025 17:43
@Copilot Copilot AI review requested due to automatic review settings June 25, 2025 17:43
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 updates the ExplicitModifications property in Lookup.cs to return a concrete Dictionary instead of an IEnumerable, optimizing performance by leveraging a struct enumerator to prevent boxing.

  • Changed the ExplicitModifications property return type from IEnumerable<KeyValuePair<string, MetadataModification>> to Dictionary<string, MetadataModification>.
  • Aims to reduce allocations during enumeration by avoiding boxing.
Comments suppressed due to low confidence (1)

src/Build/BackEnd/Components/RequestBuilder/Lookup.cs:1183

  • The XML documentation summary for ExplicitModifications still mentions 'an enumeration of the explicit metadata modifications'. Consider updating the summary to reflect that a Dictionary is returned, which may improve clarity for other developers.
            public Dictionary<string, MetadataModification> ExplicitModifications

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.

1 participant