Skip to content
This repository was 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
stephentoub merged 1 commit intodotnet:masterfrom
stephentoub:arraycopy0
Nov 4, 2019
Merged

Simplify Array.Copy(a, 0, b, 0, c) to Array.Copy(a, b, c)#42343
stephentoub merged 1 commit intodotnet:masterfrom
stephentoub:arraycopy0

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.

// 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.

// 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.

5 participants