RFR: 8301958: Reduce Arrays.copyOf/-Range overheads [v7]

Claes Redestad redestad at openjdk.org
Wed Feb 8 10:53:22 UTC 2023


On Wed, 8 Feb 2023 03:38:24 GMT, David Schlosnagle <duke at openjdk.org> wrote:

>> Claes Redestad has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Minimize, force inline, generalize
>
> src/java.base/share/classes/java/util/Arrays.java line 4142:
> 
>> 4140:     private static double[] copyOfRangeGeneric(double[] original, int from, int to) {
>> 4141:         checkLength(from, to);
>> 4142:         int newLength = to - from;
> 
> Suggestion:
> 
>         int newLength = checkLength(from, to);

> I'm also curious if returning the new length from `checkLength` would be worthwhile

I had this arrangement earlier but saw no win from it. These helper methods will be aggressively inlined and the JIT sorts it out optimally, so I prefer to keep the `check` method zoomed in on its purpose

-------------

PR: https://git.openjdk.org/jdk/pull/12453


More information about the core-libs-dev mailing list