Skip to content

Remove redundant data-contract attribute array copies - #136709

Merged
jkotas merged 1 commit into
mainfrom
stephentoub-data-contract-attribute-copies
Oct 31, 2026
Merged

jkotas merged 1 commit into
mainfrom
stephentoub-data-contract-attribute-copies

Conversation

@stephentoub

@stephentoub stephentoub commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

GetCustomAttributes(Type, bool) already returns an object[], so calling ToArray() copies an array we can use directly. Remove the eight redundant calls during data-contract discovery, avoiding the extra allocation and copy for nonempty results. The generic attribute calls that return enumerables are unchanged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@adamsitnik adamsitnik left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thank you @stephentoub !

@jkotas
jkotas merged commit c212f2e into main Oct 31, 2026
89 of 91 checks passed
@jkotas
jkotas deleted the stephentoub-data-contract-attribute-copies branch October 31, 2026 06:15
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants