mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-24 16:58:51 -05:00
Minor optimizations
This commit is contained in:
parent
6da827f0ad
commit
803413fb01
@ -473,12 +473,12 @@ public final class FileUtilities {
|
|||||||
return listFiles(folders, FILE_WALK_MAX_DEPTH, FOLDERS, order);
|
return listFiles(folders, FILE_WALK_MAX_DEPTH, FOLDERS, order);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<File> listFiles(Iterable<File> folders, int maxDepth, FileFilter filter, Comparator<File> order) {
|
public static List<File> listFiles(Iterable<File> folders, int depth, FileFilter filter, Comparator<File> order) {
|
||||||
List<File> sink = new ArrayList<File>();
|
List<File> sink = new ArrayList<File>();
|
||||||
|
|
||||||
for (File it : folders) {
|
for (File it : folders) {
|
||||||
if (it.isDirectory()) {
|
if (it.isDirectory()) {
|
||||||
listFiles(it, sink, 0, maxDepth, filter, order);
|
listFiles(it, sink, depth, filter, order);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter.accept(it)) {
|
if (filter.accept(it)) {
|
||||||
@ -489,21 +489,19 @@ public final class FileUtilities {
|
|||||||
return sink;
|
return sink;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void listFiles(File folder, List<File> sink, int depth, int maxDepth, FileFilter filter, Comparator<File> order) {
|
private static void listFiles(File folder, List<File> sink, int depth, FileFilter filter, Comparator<File> order) {
|
||||||
if (depth > maxDepth) {
|
if (depth < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (File it : getChildren(folder, NOT_HIDDEN, order)) {
|
for (File it : getChildren(folder, f -> !f.isHidden() && (f.isDirectory() || filter.accept(f)), order)) {
|
||||||
if (it.isDirectory()) {
|
if (it.isDirectory()) {
|
||||||
listFiles(it, sink, depth + 1, maxDepth, filter, order);
|
listFiles(it, sink, depth - 1, filter, order);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter.accept(it)) {
|
|
||||||
sink.add(it);
|
sink.add(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static SortedMap<File, List<File>> mapByFolder(Iterable<File> files) {
|
public static SortedMap<File, List<File>> mapByFolder(Iterable<File> files) {
|
||||||
SortedMap<File, List<File>> map = new TreeMap<File, List<File>>();
|
SortedMap<File, List<File>> map = new TreeMap<File, List<File>>();
|
||||||
|
Loading…
Reference in New Issue
Block a user