Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8272863: Replace usages of Collections.sort with List.sort call in public java modules #5229

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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
@@ -27,7 +27,6 @@

import java.util.Map;
import java.util.List;
import java.util.Collections;
import java.util.Comparator;
import java.io.IOException;
import sun.util.logging.PlatformLogger;
@@ -407,7 +406,7 @@ private boolean pathMatches(String path, String pathToMatchWith) {
* path are distinguished by creation time (older first). Method made PP to enable testing.
*/
static List<String> sortByPathAndAge(List<HttpCookie> cookies) {
Collections.sort(cookies, new CookieComparator());
cookies.sort(new CookieComparator());

List<String> cookieHeader = new java.util.ArrayList<>();
for (HttpCookie cookie : cookies) {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 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
@@ -75,7 +75,6 @@
import java.util.AbstractMap.SimpleImmutableEntry;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
@@ -553,12 +552,12 @@ static final class LocaleStore {
}
}
List<Entry<String, Long>> list = new ArrayList<>(reverse.values());
Collections.sort(list, COMPARATOR);
list.sort(COMPARATOR);
map.put(vtmEntry.getKey(), list);
allList.addAll(list);
map.put(null, allList);
}
Collections.sort(allList, COMPARATOR);
allList.sort(COMPARATOR);
this.parsable = map;
}

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 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
@@ -198,7 +198,7 @@ public synchronized InputStream getInputStream()
throw new FileNotFoundException(filename);
}

Collections.sort(files, Collator.getInstance());
files.sort(Collator.getInstance());

for (int i = 0 ; i < files.size() ; i++) {
String fileName = files.get(i);
@@ -239,7 +239,7 @@ private void checkParams(PKIXBuilderParameters params)
if (stores == null) {
// reorder CertStores so that local CertStores are tried first
stores = new ArrayList<>(params.getCertStores());
Collections.sort(stores, new CertStoreComparator());
stores.sort(new CertStoreComparator());
}
return stores;
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
@@ -63,7 +63,6 @@

package java.lang;

import java.io.*;
import java.util.*;

final class ProcessEnvironment extends HashMap<String,String>
@@ -301,7 +300,7 @@ static Map<String,String> emptyEnvironment(int capacity) {
String toEnvironmentBlock() {
// Sort Unicode-case-insensitively by name
List<Map.Entry<String,String>> list = new ArrayList<>(entrySet());
Collections.sort(list, entryComparator);
list.sort(entryComparator);

StringBuilder sb = new StringBuilder(size()*30);
int cmp = -1;
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@@ -34,7 +34,6 @@
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.UIResource;
@@ -3751,7 +3750,7 @@ TreePath[] getDisplayOrderPaths(TreePath[] paths) {
for (TreePath path : paths) {
selOrder.add(path);
}
Collections.sort(selOrder, this);
selOrder.sort(this);
int n = selOrder.size();
TreePath[] displayPaths = new TreePath[n];
for (int i = 0; i < n; i++) {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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
@@ -40,7 +40,6 @@
import java.awt.Insets;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
@@ -463,7 +462,7 @@ private void validate() {

//now that I've collected all the runtime states, I'll sort them based
//on their integer "state" (see SynthState for how this works).
Collections.sort(runtimeStates, STATE_COMPARATOR);
runtimeStates.sort(STATE_COMPARATOR);

//finally, set the array of runtime states on the values object
values.states = runtimeStates.toArray(new RuntimeState[runtimeStates.size()]);
@@ -34,7 +34,6 @@
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
@@ -346,7 +345,7 @@ public Void call() {
if (commonParent instanceof ShellFolder) {
((ShellFolder) commonParent).sortChildren(files);
} else {
Collections.sort(files, FILE_COMPARATOR);
files.sort(FILE_COMPARATOR);
}

return null;
@@ -359,7 +358,7 @@ public void sortChildren(final List<? extends File> files) {
// synchronize the whole code of the sort method once
invoke(new Callable<Void>() {
public Void call() {
Collections.sort(files, FILE_COMPARATOR);
files.sort(FILE_COMPARATOR);

return null;
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 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
@@ -246,7 +246,7 @@ protected void clearCache(XRGlyphCacheEntry[] glyps) {
* something not that stupid ;)
*/
ArrayList<XRGlyphCacheEntry> cacheList = new ArrayList<XRGlyphCacheEntry>(cacheMap.values());
Collections.sort(cacheList, new Comparator<XRGlyphCacheEntry>() {
cacheList.sort(new Comparator<XRGlyphCacheEntry>() {
public int compare(XRGlyphCacheEntry e1, XRGlyphCacheEntry e2) {
return e2.getLastUsed() - e1.getLastUsed();
}
@@ -26,7 +26,6 @@
package sun.awt.shell;

import java.awt.Image;
import java.awt.Toolkit;
import java.awt.image.AbstractMultiResolutionImage;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
@@ -36,7 +35,6 @@
import java.io.IOException;
import java.io.Serial;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
@@ -1333,7 +1331,7 @@ public void sortChildren(final List<? extends File> files) {
// synchronize the whole code of the sort method once
invoke(new Callable<Void>() {
public Void call() {
Collections.sort(files, new ColumnComparator(Win32ShellFolder2.this, 0));
files.sort(new ColumnComparator(Win32ShellFolder2.this, 0));

return null;
}