RFR: 8299199: Avoid redundant split calls in FontConfiguration.initReorderMap implementations
Alexey Ivanov
aivanov at openjdk.org
Wed Dec 21 12:12:52 UTC 2022
On Wed, 21 Dec 2022 11:56:52 GMT, Andrey Turbanov <aturbanov at openjdk.org> wrote:
>> src/java.desktop/share/classes/sun/awt/FontConfiguration.java line 856:
>>
>>> 854:
>>> 855: protected String[] split(String sequence) {
>>> 856: Vector<String> v = splitSequence(sequence);
>>
>> Can `splitSequence` be replaced with `sequence.split(",")`. The created vector is used only to convert it to array. Using `split` returns the array.
>>
>> https://github.com/openjdk/jdk/blob/7170385dd8028ad8c2c84b619bee0ade3af3ff09/src/java.desktop/share/classes/sun/awt/FontConfiguration.java#L2118
>
> Initially I was intended to do so (#11380), but I found that there is slight difference between `splitSequence` and `Strings.split` implementations. They handle empty _elements_ differently. So I think it's worth to create a separate issue to investigate if it's worth to change.
Reasonable. Thanks.
As another suggestion, since `Vector` isn't returned, `splitSequence` could use `ArrayList` internally instead.
-------------
PR: https://git.openjdk.org/jdk/pull/11754
More information about the client-libs-dev
mailing list