Small refactor for code simplicity.

This commit is contained in:
CalDescent 2022-03-11 15:11:07 +00:00
parent 9013d11d24
commit 0d0ccfd0ac

View File

@ -55,9 +55,9 @@ public class ArbitraryDataFileRequestThread implements Runnable {
// Sort by lowest number of node hops first
Comparator<ArbitraryFileListResponseInfo> lowestHopsFirstComparator =
Comparator.comparingInt(ArbitraryFileListResponseInfo::getRequestHops);
arbitraryDataFileManager.arbitraryDataFileHashResponses = arbitraryDataFileManager.arbitraryDataFileHashResponses
.stream().sorted(lowestHopsFirstComparator)
.collect(Collectors.toCollection(() -> Collections.synchronizedList(new ArrayList<>())));
List<ArbitraryFileListResponseInfo> sortedResponses = arbitraryDataFileManager.arbitraryDataFileHashResponses
.stream().sorted(lowestHopsFirstComparator).collect(Collectors.toList());
arbitraryDataFileManager.arbitraryDataFileHashResponses = Collections.synchronizedList(sortedResponses);
Iterator iterator = arbitraryDataFileManager.arbitraryDataFileHashResponses.iterator();
while (iterator.hasNext()) {