Merge "Replace LinkedList by a more performant collection"

This commit is contained in:
TreeHugger Robot
2022-02-23 20:45:04 +00:00
committed by Android (Google) Code Review

View File

@@ -62,7 +62,9 @@ import java.nio.file.FileVisitor;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
@@ -232,9 +234,9 @@ public abstract class FileSystemProvider extends DocumentsProvider {
throw new FileNotFoundException(doc + " is not found under " + parent);
}
LinkedList<String> path = new LinkedList<>();
List<String> path = new ArrayList<>();
while (doc != null && FileUtils.contains(parent, doc)) {
path.addFirst(getDocIdForFile(doc));
path.add(0, getDocIdForFile(doc));
doc = doc.getParentFile();
}
@@ -448,10 +450,10 @@ public abstract class FileSystemProvider extends DocumentsProvider {
File folder, String[] projection, Set<String> exclusion, Bundle queryArgs)
throws FileNotFoundException {
final MatrixCursor result = new MatrixCursor(resolveProjection(projection));
final LinkedList<File> pending = new LinkedList<>();
final List<File> pending = new ArrayList<>();
pending.add(folder);
while (!pending.isEmpty() && result.getCount() < 24) {
final File file = pending.removeFirst();
final File file = pending.remove(0);
if (shouldHide(file)) continue;
if (file.isDirectory()) {