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

Use List<T>.ToArray() in places #22101

Merged
merged 4 commits into from
Jan 20, 2019
Merged

Conversation

benaadams
Copy link
Member

@benaadams benaadams commented Jan 20, 2019

Also List<T>.ToArray() rather than creating a new array and then .CopyTo

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

Looks good to me otherwise. Thanks!

@benaadams
Copy link
Member Author

Checking the effects on the generics

@benaadams benaadams changed the title Use ReadOnlySpan.ToArray in places Use List<T>.ToArray() in places Jan 20, 2019
@benaadams
Copy link
Member Author

Just gone for the easy wins

Total bytes of diff: -175 (-0.01% of base)
    diff is an improvement.

Total byte diff includes 0 bytes from reconciling methods
        Base had    0 unique methods,        0 unique bytes
        Diff had    0 unique methods,        0 unique bytes

Top file improvements by size (bytes):
        -175 : System.Private.CoreLib.dasm (-0.01% of base)

1 total files with size differences (1 improved, 0 regressed), 0 unchanged.

Top method improvements by size (bytes):
         -82 : System.Private.CoreLib.dasm - RuntimeType:InvokeMember(ref,int,ref,ref,ref,ref,ref,ref):ref:this
         -57 : System.Private.CoreLib.dasm - DateTimeFormat:GetAllDateTimes(struct,ref):ref
         -36 : System.Private.CoreLib.dasm - RuntimeType:CreateInstanceImpl(int,ref,ref,ref,ref):ref:this

3 total methods with size differences (3 improved, 0 regressed), 17217 unchanged.

This had a negative impact?

Depends on how you look at it

Top method regessions by size (bytes):
          46 : System.Private.CoreLib.dasm - StackTrace:GetFrames():ref:this
          26 : System.Private.CoreLib.dasm - MemoryStream:ToArray():ref:this

However that's from the validation and throws surfacing in the methods from creating the ReadOnlySpan; its likely to be a faster path after that.

@benaadams
Copy link
Member Author

Could probably bring that back by using the ref Span constructor, but I was feeling uncontroversial ;)

@jkotas jkotas merged commit efee815 into dotnet:master Jan 20, 2019
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/corefx that referenced this pull request Jan 20, 2019
* Use ReadOnlySpan.ToArray in places

* Use List.ToArray

* Don't take .Length in to local and use as loop condition

Signed-off-by: dotnet-bot <[email protected]>
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/corert that referenced this pull request Jan 20, 2019
* Use ReadOnlySpan.ToArray in places

* Use List.ToArray

* Don't take .Length in to local and use as loop condition

Signed-off-by: dotnet-bot <[email protected]>
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/mono that referenced this pull request Jan 20, 2019
* Use ReadOnlySpan.ToArray in places

* Use List.ToArray

* Don't take .Length in to local and use as loop condition

Signed-off-by: dotnet-bot <[email protected]>
@benaadams benaadams deleted the ReadOnlySpan.ToArray branch January 20, 2019 22:58
jkotas pushed a commit to dotnet/corert that referenced this pull request Jan 20, 2019
* Use ReadOnlySpan.ToArray in places

* Use List.ToArray

* Don't take .Length in to local and use as loop condition

Signed-off-by: dotnet-bot <[email protected]>
marek-safar pushed a commit to mono/mono that referenced this pull request Jan 21, 2019
* Use ReadOnlySpan.ToArray in places

* Use List.ToArray

* Don't take .Length in to local and use as loop condition

Signed-off-by: dotnet-bot <[email protected]>
stephentoub pushed a commit to dotnet/corefx that referenced this pull request Jan 21, 2019
* Use ReadOnlySpan.ToArray in places

* Use List.ToArray

* Don't take .Length in to local and use as loop condition

Signed-off-by: dotnet-bot <[email protected]>
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* Use ReadOnlySpan.ToArray in places

* Use List.ToArray

* Don't take .Length in to local and use as loop condition


Commit migrated from dotnet/coreclr@efee815
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