On Thu, 28 Mar 2024 06:07:24 GMT, Karthik P K <k...@openjdk.org> wrote:
>> You don't need to return a list, you create it ahead of time like was done >> in line 167 >> >> List<Integer> indices = new ArrayList<>(); >> >> and the add the elements in `forEach`. > >> Why do the double-iteration pattern here and not do the `peek` operation in >> a `forEach` like in the other 2 places? > > Yes, if the usage of `forEach` in previous 2 places are correct then I would > like to see similar change here as well. I changed this to the pre-allocated pattern like in the other places. An initial capacity of `indices.length + 1` optimizes the worst case (all given indices need to be set) which probably occurs quite often in real-world usage. ------------- PR Review Comment: https://git.openjdk.org/jfx/pull/1430#discussion_r1542535713