RFR: 8253086: Optimization of removeAll and retainAll of ObservableListWrapper [v4]

yosbits github.com+7517141+yososs at openjdk.java.net
Wed Oct 7 08:10:10 UTC 2020


On Tue, 6 Oct 2020 16:36:44 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:

>> yosbits has refreshed the contents of this pull request, and previous commits have been removed. The incremental views
>> will show differences compared to the previous content of the PR.
>
> As mentioned in a reply to a comment by @kleopatra , this fix will cause a regression in behavior, and cannot be
> integrated in its current form.
> A two-pass algorithm is still needed: the first pass collects the elements to be removed, the second pass actually
> removes them. While it isn't necessary to use a BitSet to collect the indexes to be removed, that does seems a
> reasonable approach. Unless there is a good reason to change it to some other two-pass algorithm, it's probably best to
> leave it as-is, in which case this PR and the associated JBS issue can be withdrawn.

The error occurs as specified in getSelectedItems(). It seems to be correct to write the following

`listView.getItems().removeAll(new HashSet<>(selectedItems))
`

It could be interpreted that the intention was to mitigate the side effects associated with the getSelectedItems()
specification.

The use of BitSet should be avoided when the list is large, as it is not a sparse implementation and therefore wastes a
lot of memory. For example, when removing the last item in the list.

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

PR: https://git.openjdk.java.net/jfx/pull/305


More information about the openjfx-dev mailing list