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

Add a fast path for byte[] to Buffer.BlockCopy #3118

Merged
merged 1 commit into from
Feb 11, 2016

Conversation

jkotas
Copy link
Member

@jkotas jkotas commented Feb 10, 2016

No description provided.

@jkotas
Copy link
Member Author

jkotas commented Feb 10, 2016

cc @geoffkizer

MethodTable * pByteArrayMT = g_pByteArrayMT;
if (pByteArrayMT == NULL)
{
if (g_pPredefinedArrayTypes[ELEMENT_TYPE_U1] != NULL)
Copy link
Member

Choose a reason for hiding this comment

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

In what situations will this be null? Just curious, as until it's not null it looks like we won't take the fast path.

Copy link
Member Author

Choose a reason for hiding this comment

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

It could be NULL if it is called early during startup. It may be better to initialize it at known point during startup sequence ... to save the check for NULL, and the ambiguity about whether it may be NULL. I will do the change...

@stephentoub
Copy link
Member

LGTM

1 similar comment
@geoffkizer
Copy link

LGTM

jkotas added a commit that referenced this pull request Feb 11, 2016
Add a fast path for byte[] to Buffer.BlockCopy
@jkotas jkotas merged commit 85c57ca into dotnet:master Feb 11, 2016
stephentoub added a commit to stephentoub/corefx that referenced this pull request Feb 14, 2016
In particular after dotnet/coreclr#3118, Buffer.BlockCopy has less overhead than Array.Copy when copying byte[]s, such that there's no benefit to using Array.Copy and potential benefit to using Buffer.BlockCopy.

This commit replaces usage of Array.Copy(byte[], ...) in corefx with Buffer.BlockCopy(byte[], ...).  A lot of places were already using it.

(In a few places where we weren't passing lower bounds to Array.Copy with T[] arguments, I added explicit lower bounds as well to avoid the overload needing to call GetLowerBound.)
stephentoub added a commit to stephentoub/corefx that referenced this pull request Feb 14, 2016
In particular after dotnet/coreclr#3118, Buffer.BlockCopy has less overhead than Array.Copy when copying byte[]s, such that there's no benefit to using Array.Copy and potential benefit to using Buffer.BlockCopy.

This commit replaces usage of Array.Copy(byte[], ...) in corefx with Buffer.BlockCopy(byte[], ...).  A lot of places were already using it.

(In a few places where we weren't passing lower bounds to Array.Copy with T[] arguments, I added explicit lower bounds as well to avoid the overload needing to call GetLowerBound.)
stephentoub added a commit to stephentoub/corefx that referenced this pull request Feb 14, 2016
In particular after dotnet/coreclr#3118, Buffer.BlockCopy has less overhead than Array.Copy when copying byte[]s, such that there's no benefit to using Array.Copy and potential benefit to using Buffer.BlockCopy.

This commit replaces usage of Array.Copy(byte[], ...) in corefx with Buffer.BlockCopy(byte[], ...).  A lot of places were already using it.

(In a few places where we weren't passing lower bounds to Array.Copy with T[] arguments, I added explicit lower bounds as well to avoid the overload needing to call GetLowerBound.)
@jkotas jkotas deleted the buffercopy branch February 25, 2016 06:26
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
In particular after dotnet/coreclr#3118, Buffer.BlockCopy has less overhead than Array.Copy when copying byte[]s, such that there's no benefit to using Array.Copy and potential benefit to using Buffer.BlockCopy.

This commit replaces usage of Array.Copy(byte[], ...) in corefx with Buffer.BlockCopy(byte[], ...).  A lot of places were already using it.

(In a few places where we weren't passing lower bounds to Array.Copy with T[] arguments, I added explicit lower bounds as well to avoid the overload needing to call GetLowerBound.)


Commit migrated from dotnet/corefx@3ab3bd6
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants