Skip to content

Avoid unnecessary byte[] allocation in Baml2006Reader.Process_Header#6276

Merged
dipeshmsft merged 2 commits intodotnet:mainfrom
stephentoub:avoidbytesread
Jun 3, 2022
Merged

Avoid unnecessary byte[] allocation in Baml2006Reader.Process_Header#6276
dipeshmsft merged 2 commits intodotnet:mainfrom
stephentoub:avoidbytesread

Conversation

@stephentoub
Copy link
Member

Description

Baml2006Reader.Process_Header skips past data from the reader, but it does so by calling BinaryReader.ReadBytes, which allocates, fills, and returns an array, which Process_Header promptly ignores. We can instead just change the position on the stream, or worst case if it's not seekable, read into a temporarily rented array.

Customer Impact

Unnecessary array allocations.

Regression

No

Testing

CI

Risk

Minimal.

@stephentoub stephentoub requested a review from a team as a code owner March 18, 2022 01:53
@ghost ghost added the PR metadata: Label to tag PRs, to facilitate with triage label Mar 18, 2022
@ghost ghost requested review from SamBent, dipeshmsft and singhashish-wpf March 18, 2022 01:53
@dipeshmsft dipeshmsft self-assigned this May 5, 2022
@ghost ghost assigned stephentoub May 5, 2022
@dipeshmsft dipeshmsft merged commit ab8390a into dotnet:main Jun 3, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jul 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

PR metadata: Label to tag PRs, to facilitate with triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants