Skip to content

Commit

Permalink
8301342: Prefer ArrayList to LinkedList in LayoutComparator
Browse files Browse the repository at this point in the history
Backport-of: d67bfe21a23fea2d9ef4eef4e811b774cca2ab94
  • Loading branch information
Victor Rudometov authored and Paul Hohensee committed Feb 20, 2023
1 parent 5027f56 commit 49ff97c
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -24,8 +24,8 @@
*/
package javax.swing;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.awt.Component;
import java.awt.ComponentOrientation;
Expand Down Expand Up @@ -63,7 +63,7 @@ public int compare(Component a, Component b) {
// each Component and then search from the Window down until the
// hierarchy branches.
if (a.getParent() != b.getParent()) {
LinkedList<Component> aAncestory = new LinkedList<Component>();
ArrayList<Component> aAncestory = new ArrayList<>();

for(; a != null; a = a.getParent()) {
aAncestory.add(a);
Expand All @@ -76,7 +76,7 @@ public int compare(Component a, Component b) {
throw new ClassCastException();
}

LinkedList<Component> bAncestory = new LinkedList<Component>();
ArrayList<Component> bAncestory = new ArrayList<>();

for(; b != null; b = b.getParent()) {
bAncestory.add(b);
Expand Down

1 comment on commit 49ff97c

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.