Call 'toArray()' with an empty array instead of a pre-sized array#5277
Conversation
Calls to `Collection.toArray()` is not consistent and in many places and use a pre-sized array parameter. This change makes a consistent use of the `toArray(new T[0])`. The empty array usage is considered faster, safer and cleaner than the sized based array approach. Signed-off-by: Rabi Panda <adnapibar@gmail.com>
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
Signed-off-by: Rabi Panda <adnapibar@gmail.com>
Gradle Check (Jenkins) Run Completed with:
|
|
Just a comment on the subject, seems like similar changes are making its way into JDK (https://bugs.openjdk.org/browse/JDK-8258804 fe) |
|
Just for the record, it seems like |
No, I think the issue is just to update it internally in JDK. This is the commit openjdk/jdk@39e03a0b |
I think I misunderstood your comment earlier. Yes, there were a few places they have updated it. |
…ensearch-project#5277) Calls to `Collection.toArray()` is not consistent and in many places and use a pre-sized array parameter. This change makes a consistent use of the `toArray(new T[0])`. The empty array usage is considered faster, safer and cleaner than the sized based array approach. Signed-off-by: Rabi Panda <adnapibar@gmail.com>
) (#16563) Calls to `Collection.toArray()` is not consistent and in many places and use a pre-sized array parameter. This change makes a consistent use of the `toArray(new T[0])`. The empty array usage is considered faster, safer and cleaner than the sized based array approach. Signed-off-by: Rabi Panda <adnapibar@gmail.com> Co-authored-by: Rabi Panda <adnapibar@gmail.com>
Description
Calls to
Collection.toArray()is not consistent and in many places and use a pre-sized array parameter. This change refactors the calls to consistently usetoArray(new T[0]). The empty array usage is considered faster, safer and cleaner than the sized based array approach.Ref: https://shipilev.net/blog/2016/arrays-wisdom-ancients/
Issues Resolved
N/A
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.
Signed-off-by: Rabi Panda adnapibar@gmail.com