On Tue, 31 May 2022 14:51:48 GMT, Daniel Fuchs <dfu...@openjdk.org> wrote:
>> Jaikiran Pai has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Use Collection.toArray(...) instead of creating a copy of the collection > > src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java line 384: > >> 382: final Set<SelectionKey> copy = new >> HashSet<>(selected); >> 383: // iterate over the copy >> 384: for (final SelectionKey key : copy) { > > Another possibility would be to call toArray() - since we're simply going to > iterate we don't need a full copy of the hashset - e.g.: `for (var key : > selected.toArray(SelectionKey[]::new)) {` That's a good idea. I've now updated the PR to use this suggestion. ------------- PR: https://git.openjdk.java.net/jdk/pull/8898