RFR: 8283346: Optimize observable ArrayList creation in FXCollections [v4]
Marius Hanl
mhanl at openjdk.org
Tue Jun 28 17:00:14 UTC 2022
On Tue, 28 Jun 2022 16:23:57 GMT, Nir Lisker <nlisker at openjdk.org> wrote:
>> Marius Hanl has updated the pull request incrementally with one additional commit since the last revision:
>>
>> 8283346: add items directly to the backing list to save a change build caused by adding items to the observable list
>
> 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.
-------------
PR: https://git.openjdk.org/jfx/pull/758
More information about the openjfx-dev
mailing list