Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8274899: Replace usages of Collections.sort with List.sort call in jd…
…k.hotspot.agent

Reviewed-by: sspitsyn, cjplummer, ayang
  • Loading branch information
turbanoff authored and albertnetymk committed Oct 19, 2021
1 parent 002c538 commit a579483
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 26 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2021, 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 Down Expand Up @@ -137,7 +137,7 @@ public void resolve(ResolveListener listener) {

// Sort blocks in ascending order of starting address (but do not
// change ordering among blocks with the same starting address)
Collections.sort(blocks, new Comparator<>() {
blocks.sort(new Comparator<>() {
public int compare(BlockSym b1, BlockSym b2) {
Address a1 = b1.getAddress();
Address a2 = b2.getAddress();
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2021, 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 Down Expand Up @@ -50,7 +50,7 @@ public void addLineNumberInfo(BasicLineNumberInfo info) {
counter. This must be done before any queries are made. */
public void sort() {
if (infoList == null) return;
Collections.sort(infoList, new Comparator<>() {
infoList.sort(new Comparator<>() {
public int compare(BasicLineNumberInfo l1, BasicLineNumberInfo l2) {
Address a1 = l1.getStartPC();
Address a2 = l2.getStartPC();
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2021, 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 Down Expand Up @@ -365,7 +365,7 @@ private List<Address> collectLiveRegions() {
}

private void sortLiveRegions(List<Address> liveRegions) {
Collections.sort(liveRegions, new Comparator<Address>() {
liveRegions.sort(new Comparator<Address>() {
public int compare(Address a1, Address a2) {
if (AddressOps.lt(a1, a2)) {
return -1;
Expand Down
Expand Up @@ -50,11 +50,7 @@ public void epilogue() {}
public List<ObjectHistogramElement> getElements() {
List<ObjectHistogramElement> list = new ArrayList<>();
list.addAll(map.values());
Collections.sort(list, new Comparator<>() {
public int compare(ObjectHistogramElement o1, ObjectHistogramElement o2) {
return o1.compare(o2);
}
});
list.sort(ObjectHistogramElement::compare);
return list;
}

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2021, 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 Down Expand Up @@ -30,7 +30,6 @@
import sun.jvm.hotspot.utilities.SystemDictionaryHelper;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;

Expand Down Expand Up @@ -126,11 +125,7 @@ public void doOop(OopField field, boolean isVMField) {
*/
ArrayList<ObjectHistogramElement> list = new ArrayList<>();
list.addAll(map.values());
Collections.sort(list, new Comparator<>() {
public int compare(ObjectHistogramElement o1, ObjectHistogramElement o2) {
return o1.compare(o2);
}
});
list.sort(ObjectHistogramElement::compare);

/*
* Print summary of objects in queue
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2021, 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 Down Expand Up @@ -28,7 +28,6 @@
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;

import sun.jvm.hotspot.debugger.*;
Expand Down Expand Up @@ -202,7 +201,7 @@ public int compare(ProcessInfo o1, ProcessInfo o2) {
}
};
}
Collections.sort(els, c);
els.sort(c);
}

private javax.swing.Timer getTimer() {
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2021, 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,9 +24,6 @@

package sun.jvm.hotspot.ui.table;

import java.util.Collections;
import java.util.List;

import javax.swing.event.TableModelEvent;
import javax.swing.table.AbstractTableModel;

Expand Down Expand Up @@ -55,7 +52,7 @@ public void sortByColumn(int column, boolean ascending) {
comparator.addColumn(column);
comparator.setAscending(ascending);

Collections.sort(elements, comparator);
elements.sort(comparator);

fireTableChanged(new TableModelEvent(this));
}
Expand Down

1 comment on commit a579483

@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.