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

Simplify Array.Copy(a, 0, b, 0, c) to Array.Copy(a, b, c) #42343

Merged
merged 1 commit into from
Nov 4, 2019

Conversation

stephentoub
Copy link
Member

corefx side of dotnet/coreclr#27641.
cc: @jkotas

VS regex search and replace from Array.Copy\((.+), 0, (.+), 0 to Array.Copy($1, $2. The only changes I reverted were those to the tests for Array itself.

@@ -69,7 +69,7 @@ private ICryptoTransform CreateTransform(byte[] rgbKey, byte[] rgbIV, bool encry
// Some platforms do not support Two-Key Triple DES, so manually support it here.
// Two-Key Triple DES contains two 8-byte keys {K1}{K2} with {K1} appended to make {K1}{K2}{K1}.
byte[] newkey = new byte[24];
Array.Copy(rgbKey, 0, newkey, 0, 16);
Array.Copy(rgbKey, newkey, 16);
Copy link
Member

Choose a reason for hiding this comment

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

IMO the original code reads a bit cleaner since it's more obvious that the destination array is being written piecemeal. But honestly it's only a weakly held opinion.

@@ -124,7 +124,7 @@ byte[] ICngSymmetricAlgorithm.PreprocessKey(byte[] key)
// Cng does not support Two-Key Triple DES, so manually support it here for consistency with System.Security.Cryptography.Algorithms.
// Two-Key Triple DES contains two 8-byte keys {K1}{K2} with {K1} appended to make {K1}{K2}{K1}.
byte[] newkey = new byte[24];
Array.Copy(key, 0, newkey, 0, 16);
Array.Copy(key, newkey, 16);
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

VS regex search and replace from `Array.Copy\((.+), 0, (.+), 0` to `Array.Copy($1, $2`, then manually reviewed.  The only changes I reverted were those to the tests for Array itself.
@stephentoub stephentoub merged commit 5ac93ba into dotnet:master Nov 4, 2019
@stephentoub stephentoub deleted the arraycopy0 branch November 4, 2019 11:16
@karelz karelz added this to the 5.0 milestone Dec 19, 2019
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…efx#42343)

VS regex search and replace from `Array.Copy\((.+), 0, (.+), 0` to `Array.Copy($1, $2`, then manually reviewed.  The only changes I reverted were those to the tests for Array itself.

Commit migrated from dotnet/corefx@5ac93ba
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.

None yet

5 participants