RFR: 8359996: Remove unnecessary List.indexOf key from Track.remove

Chen Liang liach at openjdk.org
Thu Jun 19 07:38:55 UTC 2025


On Wed, 23 Apr 2025 08:53:57 GMT, Andrey Turbanov <aturbanov at openjdk.org> wrote:

> No need to call `List.indexOf(Object)` before `List.remove(int)`. Instead we can call `List.remove(Object)` directly. It's faster and cleaner.
> `eventsList` is an ArrayList.

src/java.desktop/share/classes/javax/sound/midi/Track.java line 202:

> 200:         synchronized(eventsList) {
> 201:             if (set.remove(event)) {
> 202:                 if (eventsList.remove(event)) {

Can be rewritten as `if (set.remove(event) && eventsList.remove(event))`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24818#discussion_r2056560123


More information about the client-libs-dev mailing list