RFR: 8283346: Optimize observable ArrayList creation in FXCollections [v4]
Nir Lisker
nlisker at openjdk.org
Tue Jun 28 17:29:56 UTC 2022
On Tue, 28 Jun 2022 16:56:27 GMT, Marius Hanl <mhanl at openjdk.org> wrote:
>> modules/javafx.base/src/main/java/javafx/collections/FXCollections.java line 351:
>>
>>> 349: public static <E> ObservableList<E> observableArrayList(E... items) {
>>> 350: ArrayList<E> backingList = new ArrayList<>(items.length);
>>> 351: backingList.addAll(Arrays.asList(items));
>>
>> Did you try using `List.of` instead?
>>
>> var backingList = new ArrayList<>(List.of(items));
>
> No, but `List.of` does not allow `null` values, therefore this would change the existing behaviour as `null` is allowed in an observable arraylist.
That's a good point.
-------------
PR: https://git.openjdk.org/jfx/pull/758
More information about the openjfx-dev
mailing list