RFR: 8261847: performace of java.lang.Record::toString should be improved [v4]
Claes Redestad
redestad at openjdk.java.net
Mon Nov 22 16:19:23 UTC 2021
On Mon, 22 Nov 2021 16:03:16 GMT, Jim Laskey <jlaskey at openjdk.org> wrote:
>> src/java.base/share/classes/java/lang/runtime/ObjectMethods.java line 314:
>>
>>> 312: ).getTarget();
>>> 313: mhs[splitIndex] = MethodHandles.filterArguments(mhs[splitIndex], 0, currentSplitGetters);
>>> 314: mhs[splitIndex] = MethodHandles.permuteArguments(
>>
>> This is some gnarly logic. Could we add some comments on what permuteArguments with a reorder array of just zeros is doing here?
>
> This is not unusual. It spreads a single argument across several "getters". But a comment wouldn't hurt.
I haven't seen it used like this before. The duplication behavior is mentioned explicitly with an example in the javadoc, sure, but it still took me a deep reading of the docs to understand what was going on here and what the intent was.
-------------
PR: https://git.openjdk.java.net/jdk/pull/6403
More information about the core-libs-dev
mailing list