simplification: replaces Collections.sort with List.sort in intellij.platform.util module

This commit is contained in:
nik
2019-02-11 20:37:05 +03:00
parent d3937dfa82
commit 2ee2f6b0ae
9 changed files with 11 additions and 11 deletions
@@ -21,7 +21,6 @@ import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.TextRange;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
@@ -34,7 +33,7 @@ public class FragmentListImpl implements FragmentList {
}
private void init() {
Collections.sort(myFragments, FRAGMENT_COMPARATOR);
myFragments.sort(FRAGMENT_COMPARATOR);
myFragments.trimToSize();
}
@@ -109,7 +109,7 @@ public class StringUtil extends StringUtilRt {
public static List<String> getWordsInStringLongestFirst(@NotNull String find) {
List<String> words = getWordsIn(find);
// hope long words are rare
Collections.sort(words, (o1, o2) -> o2.length() - o1.length());
words.sort((o1, o2) -> o2.length() - o1.length());
return words;
}
@@ -1808,7 +1808,7 @@ public class ContainerUtil extends ContainerUtilRt {
}
}
else {
Collections.sort(list, comparator);
list.sort(comparator);
}
}
@@ -805,7 +805,7 @@ public abstract class JBIterable<E> implements Iterable<E> {
@NotNull
public final JBIterable<E> sort(@NotNull Comparator<? super E> comparator) {
ArrayList<E> list = addAllTo(ContainerUtilRt.<E>newArrayList());
Collections.sort(list, comparator);
list.sort(comparator);
return from(list);
}
@@ -370,7 +370,7 @@ public class DFSTBuilder<Node> {
@NotNull
public List<Node> getSortedNodes() {
List<Node> result = new ArrayList<>(myGraph.getNodes());
Collections.sort(result, comparator());
result.sort(comparator());
return result;
}
}
@@ -280,7 +280,8 @@ public class PersistentHashMapValueStorage {
private long compactValuesWithoutChunks(@NotNull List<? extends PersistentHashMap.CompactionRecordInfo> infos, @NotNull PersistentHashMapValueStorage storage)
throws IOException {
//infos = new ArrayList<PersistentHashMap.CompactionRecordInfo>(infos);
Collections.sort(infos, (Comparator<PersistentHashMap.CompactionRecordInfo>)(info, info2) -> Comparing.compare(info.valueAddress, info2.valueAddress));
infos
.sort((Comparator<PersistentHashMap.CompactionRecordInfo>)(info, info2) -> Comparing.compare(info.valueAddress, info2.valueAddress));
final int fileBufferLength = 256 * 1024;
final byte[] buffer = new byte[fileBufferLength];
@@ -53,7 +53,7 @@ public class ReorderJarsMain {
final List<JBZipEntry> entries = zipFile.getEntries();
final List<String> orderedEntries = toReorder.get(jarUrl);
assert orderedEntries.size() <= Short.MAX_VALUE : jarUrl;
Collections.sort(entries, (o1, o2) -> {
entries.sort((o1, o2) -> {
if ("META-INF/plugin.xml".equals(o2.getName())) return Integer.MAX_VALUE;
if ("META-INF/plugin.xml".equals(o1.getName())) return -Integer.MAX_VALUE;
if (orderedEntries.contains(o1.getName())) {
@@ -49,7 +49,7 @@ public class TextRangeUtil {
public static Iterable<TextRange> excludeRanges(@NotNull TextRange original, @NotNull List<? extends TextRange> excludedRanges) {
if (!excludedRanges.isEmpty()) {
if (excludedRanges.size() > 1) {
Collections.sort(excludedRanges, RANGE_COMPARATOR);
excludedRanges.sort(RANGE_COMPARATOR);
}
int enabledRangeStart = original.getStartOffset();
List<TextRange> enabledRanges = new ArrayList<>();
@@ -126,7 +126,7 @@ public final class FontInfo {
if (info != null) list.add(info);
}
}
Collections.sort(list, COMPARATOR);
list.sort(COMPARATOR);
return Collections.unmodifiableList(list);
}
@@ -145,7 +145,7 @@ public final class FontInfo {
FontInfo info = find(list, name);
if (info != null) list.remove(info);
}
Collections.sort(list, COMPARATOR);
list.sort(COMPARATOR);
return Collections.unmodifiableList(list);
}