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

Don't use Array.Reverse in ImmutableArray<T>.Builder.Reverse #2354

Merged
merged 1 commit into from
Jul 14, 2015

Conversation

justinvp
Copy link
Contributor

The non-generic Array.Reverse does not perform well for non-primitive value types.

See the following for details:
dotnet/coreclr#1231

Note: I considered adding a common ArrayHelpers class, as there are some other uses of Array.Reverse in corefx. However, the other uses didn't seem to warrant the use of the improved Reverse:

  • Crypto calls Array.Reverse on byte[] which is a primitive type that Array.Reverse has a fast-path for (example, example, etc.).
  • Stack<T>.CopyTo calls Array.Reverse only in a rare case
  • ReadOnlyCollectionBuilder<T> is internal and it doesn't look like ReadOnlyCollectionBuilder.Reverse is actually used at all.

The non-generic Array.Reverse does not perform well for non-primitive
value types.
@stephentoub
Copy link
Member

LGTM. Thanks.

stephentoub added a commit that referenced this pull request Jul 14, 2015
Don't use Array.Reverse in ImmutableArray<T>.Builder.Reverse
@stephentoub stephentoub merged commit 77b5b79 into dotnet:master Jul 14, 2015
@justinvp justinvp deleted the immutablearray branch October 1, 2015 22:19
@karelz karelz modified the milestone: 1.0.0-rtm Dec 3, 2016
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Don't use Array.Reverse in ImmutableArray<T>.Builder.Reverse

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

4 participants