RFR: 8362067: Remove unnecessary List.contains key from SpringLayout.Constraints.pushConstraint

Damon Nguyen dnguyen at openjdk.org
Thu Jul 31 19:55:01 UTC 2025


On Thu, 24 Apr 2025 14:53:20 GMT, Andrey Turbanov <aturbanov at openjdk.org> wrote:

> There is no need to call `List.contains` before `List.remove` call.
> `history` is an either `horizontalHistory` or `verticalHistory`. Both of them are ArrayList's.

Seems perfectly OK to me. `remove` inherently handles the cases where `name` doesn't occur, so `contains` is redundant. Built the change fine. Ran a sample test to confirm everything works as expected. LGTM after wildcard import change.

src/java.desktop/share/classes/javax/swing/SpringLayout.java line 32:

> 30: import java.awt.Insets;
> 31: import java.awt.LayoutManager2;
> 32: import java.util.*;

Can you expand the wildcard import since we're touching this part of the file anyway?


package javax.swing;

import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.LayoutManager2;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

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

Changes requested by dnguyen (Committer).

PR Review: https://git.openjdk.org/jdk/pull/24852#pullrequestreview-3076709112
PR Review Comment: https://git.openjdk.org/jdk/pull/24852#discussion_r2246251589


More information about the client-libs-dev mailing list