Re: RFR: 8273349: Check uses of Stream::peek in controls and replace as needed [v2]

2024-03-28 Thread drmarmac
On Thu, 28 Mar 2024 06:07:24 GMT, Karthik P K wrote: >> You don't need to return a list, you create it ahead of time like was done >> in line 167 >> >> List indices = new ArrayList<>(); >> >> and the add the elements in `forEach`. > >> Why do the double-iteration pattern here and not do the

Re: RFR: 8273349: Check uses of Stream::peek in controls and replace as needed [v2]

2024-03-28 Thread Karthik P K
On Wed, 27 Mar 2024 23:21:34 GMT, Nir Lisker wrote: >> `forEach` is void, so we can not return a list afterwards. > > You don't need to return a list, you create it ahead of time like was done in > line 167 > > List indices = new ArrayList<>(); > > and the add the elements in `forEach`. >

Re: RFR: 8273349: Check uses of Stream::peek in controls and replace as needed [v2]

2024-03-28 Thread Karthik P K
On Wed, 27 Mar 2024 23:24:51 GMT, Marius Hanl wrote: >>> In the java.util.stream package >>> [docs](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/util/stream/package-summary.html#SideEffects) >>> it is mentioned that `forEach()` method operates only via side-effects. So

Re: RFR: 8273349: Check uses of Stream::peek in controls and replace as needed [v2]

2024-03-27 Thread Marius Hanl
On Wed, 27 Mar 2024 13:41:21 GMT, Nir Lisker wrote: > That's still 2 iterations. Yes, but one advantage here: We currently do `final List removed = new ArrayList<>(c.getRemovedSize());`, where we allocate a list with a size, that is probably too big since we filter the removed items. So with

Re: RFR: 8273349: Check uses of Stream::peek in controls and replace as needed [v2]

2024-03-27 Thread Nir Lisker
On Wed, 27 Mar 2024 23:18:43 GMT, Marius Hanl wrote: >> modules/javafx.controls/src/main/java/javafx/scene/control/MultipleSelectionModelBase.java >> line 773: >> >>> 771: .collect(Collectors.toList()); >>> 772: >>> 773:

Re: RFR: 8273349: Check uses of Stream::peek in controls and replace as needed [v2]

2024-03-27 Thread Marius Hanl
On Wed, 27 Mar 2024 13:51:46 GMT, Nir Lisker wrote: >> drmarmac has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Remove outdated comment > > modules/javafx.controls/src/main/java/javafx/scene/control/MultipleSelectionModelBase.java >

Re: RFR: 8273349: Check uses of Stream::peek in controls and replace as needed [v2]

2024-03-27 Thread Nir Lisker
On Wed, 27 Mar 2024 09:11:56 GMT, drmarmac wrote: >> This PR removes potentially incorrect usages of Stream.peek(). >> The changed code should be covered by the tests that are already present. > > drmarmac has updated the pull request incrementally with one additional > commit since the last

Re: RFR: 8273349: Check uses of Stream::peek in controls and replace as needed [v2]

2024-03-27 Thread Nir Lisker
On Wed, 27 Mar 2024 12:23:47 GMT, Marius Hanl wrote: >> I'd say .forEach() is used correctly here, according to docs, it guarantees >> execution of the side-effects (add to removed list & clear index), just not >> in any particular order. This way we avoid multiple iteration. > > Another idea

Re: RFR: 8273349: Check uses of Stream::peek in controls and replace as needed [v2]

2024-03-27 Thread Marius Hanl
On Wed, 27 Mar 2024 09:07:15 GMT, drmarmac wrote: >> modules/javafx.controls/src/main/java/javafx/scene/control/ControlUtils.java >> line 176: >> >>> 174: .distinct() >>> 175: .filter(removeRowFilter) >>> 176: .forEach(row -> { >> >>

Re: RFR: 8273349: Check uses of Stream::peek in controls and replace as needed [v2]

2024-03-27 Thread drmarmac
On Tue, 26 Mar 2024 16:32:53 GMT, Karthik P K wrote: >> drmarmac has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Remove outdated comment > > modules/javafx.controls/src/main/java/javafx/scene/control/ControlUtils.java > line 176: > >>

Re: RFR: 8273349: Check uses of Stream::peek in controls and replace as needed [v2]

2024-03-27 Thread drmarmac
> This PR removes potentially incorrect usages of Stream.peek(). > The changed code should be covered by the tests that are already present. drmarmac has updated the pull request incrementally with one additional commit since the last revision: Remove outdated comment - Changes: