Minor optimizations

This commit is contained in:
Reinhard Pointner 2016-10-07 01:47:10 +08:00
parent f7d45346fd
commit f6a473a816
1 changed files with 4 additions and 2 deletions

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) {