Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Buffer.BlockCopy: Avoid double-typechecks for arrays of same type - #4807

Merged
jkotas merged 1 commit into
dotnet:masterfrom
jamesqo:patch-6
May 7, 2016
Merged

jkotas merged 1 commit into
dotnet:masterfrom
jamesqo:patch-6

Conversation

@jamesqo

@jamesqo jamesqo commented May 5, 2016 •

Copy link
Copy Markdown

Small optimization in Buffer.BlockCopy: we don't need to perform another type check if the source/destination method tables are the same (which I'm assuming correspond to the same instance if the arrays are of the same type). This helps for copying between non-byte arrays of the same type, e.g.

var src = new char[3] { 'A', 'B', 'C' };
var dest = new char[3];
Buffer.BlockCopy(src, 0, dest, 0, src.Length * sizeof(char));

cc @jkotas

@jamesqo

jamesqo commented May 6, 2016

Copy link
Copy Markdown
Author

@dotnet-bot test this please

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants