Skip to content

Use Buffer.BlockCopy with byte[] - #1366

Merged
DavoudEshtehari merged 1 commit into
dotnet:mainfrom
Kaur-Parminder:ReplaceArrayCopyWithBufferBlockCopy
Jan 26, 2022
Merged

Use Buffer.BlockCopy with byte[]#1366
DavoudEshtehari merged 1 commit into
dotnet:mainfrom
Kaur-Parminder:ReplaceArrayCopyWithBufferBlockCopy

Conversation

@Kaur-Parminder

Copy link
Copy Markdown
Contributor

This change is based on changes done dotnet/corefx@3ab3bd6. I have replaced Array.Copy wherever there is byte[]. Buffer.BlockCopy has less overhead than Array.Copy when copying byte[]s.

This change is based on changes done dotnet/corefx@3ab3bd6. I have replaced Array.Copy wherever there is byte[]. Buffer.BlockCopy has less overhead than Array.Copy when copying byte[]s.
@Wraith2

Wraith2 commented Oct 21, 2021

Copy link
Copy Markdown
Contributor

I don't object but I also don't think this will make any measurable difference to performance.

@Kaur-Parminder

Copy link
Copy Markdown
Contributor Author

I don't object but I also don't think this will make any measurable difference to performance.

It is debatable at many resources if there is performance difference or not. I have added this to diverge the difference between netfx and netcore and to be consistent across all files, responding to the comment #1337 (comment)

@cheenamalhotra cheenamalhotra added the Code Health 💊 Issues/PRs that are targeted to source code quality improvements. label Oct 25, 2021
@JRahnama JRahnama added this to the 5.0.0-preview1 milestone Dec 7, 2021
@JRahnama

Copy link
Copy Markdown
Contributor

working with bytes are more difficult than working with indexes and may cause debugging to be more complicated, but since the data is already in bytes no issue here. Looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Code Health 💊 Issues/PRs that are targeted to source code quality improvements.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants