Skip to content

Commit

Permalink
8301342: Prefer ArrayList to LinkedList in LayoutComparator
Browse files Browse the repository at this point in the history
Reviewed-by: prr, serb
  • Loading branch information
Andrey Turbanov committed Feb 5, 2023
1 parent 3449324 commit d67bfe2
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 @@ -70,7 +70,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 @@ -83,7 +83,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

3 comments on commit d67bfe2

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@Rudometov
Copy link
Member

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on d67bfe2 Feb 17, 2023

Choose a reason for hiding this comment

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

@Rudometov the backport was successfully created on the branch Rudometov-backport-d67bfe21 in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit d67bfe21 from the openjdk/jdk repository.

The commit being backported was authored by Andrey Turbanov on 5 Feb 2023 and was reviewed by Phil Race and Sergey Bylokhov.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev Rudometov-backport-d67bfe21:Rudometov-backport-d67bfe21
$ git checkout Rudometov-backport-d67bfe21
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev Rudometov-backport-d67bfe21

Please sign in to comment.