1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-24 16:58:51 -05:00

Minor optimizations

This commit is contained in:
Reinhard Pointner 2016-10-07 01:47:10 +08:00
parent f7d45346fd
commit f6a473a816

View File

@ -51,14 +51,16 @@ class FilesListTransferablePolicy extends BackgroundFileTransferablePolicy<File>
@Override @Override
protected void load(List<File> files, TransferAction action) { protected void load(List<File> files, TransferAction action) {
// use fast file to minimize system calls like length(), isDirectory(), isFile(), ...
files.replaceAll(FastFile::new);
// collect files recursively and eliminate duplicates // collect files recursively and eliminate duplicates
Set<File> sink = new LinkedHashSet<File>(64, 4); Set<File> sink = new LinkedHashSet<File>(64, 4);
// load files recursively by default // load files recursively by default
load(files, action != TransferAction.LINK, sink); load(files, action != TransferAction.LINK, sink);
// use fast file to minimize system calls like length(), isDirectory(), isFile(), ... and list files in human order publish(sink.toArray(new File[0]));
publish(sink.stream().map(FastFile::new).toArray(File[]::new));
} }
private void load(List<File> files, boolean recursive, Collection<File> sink) { private void load(List<File> files, boolean recursive, Collection<File> sink) {