diff --git a/source/net/filebot/cli/ScriptShellMethods.java b/source/net/filebot/cli/ScriptShellMethods.java index 7fd1dbba..d52213e6 100644 --- a/source/net/filebot/cli/ScriptShellMethods.java +++ b/source/net/filebot/cli/ScriptShellMethods.java @@ -240,7 +240,7 @@ public class ScriptShellMethods { } public static FastFile memoize(File self) { - return new FastFile(self.getPath()); + return new FastFile(self); } public static File moveTo(File self, File destination) throws IOException { diff --git a/source/net/filebot/media/MediaDetection.java b/source/net/filebot/media/MediaDetection.java index 8c6c25dc..71e32812 100644 --- a/source/net/filebot/media/MediaDetection.java +++ b/source/net/filebot/media/MediaDetection.java @@ -1,6 +1,5 @@ package net.filebot.media; - import static java.util.Arrays.*; import static java.util.Collections.*; import static java.util.regex.Pattern.*; @@ -1402,21 +1401,6 @@ public class MediaDetection { } } - public static List getMediaUnits(File folder) { - if (folder.isHidden()) { - return emptyList(); - } - - if (folder.isDirectory() && !isDiskFolder(folder)) { - List children = new ArrayList(); - for (File f : getChildren(folder)) { - children.addAll(getMediaUnits(f)); - } - } - - return singletonList(folder); - } - public static void warmupCachedResources() throws Exception { // load filter data MediaDetection.getClutterFileFilter(); diff --git a/source/net/filebot/ui/filter/FileTreeTransferablePolicy.java b/source/net/filebot/ui/filter/FileTreeTransferablePolicy.java index 4e35c5cb..aae92810 100644 --- a/source/net/filebot/ui/filter/FileTreeTransferablePolicy.java +++ b/source/net/filebot/ui/filter/FileTreeTransferablePolicy.java @@ -69,7 +69,7 @@ class FileTreeTransferablePolicy extends BackgroundFileTransferablePolicy // load files recursively by default load(files, action != TransferAction.LINK, fileset); - publish(FastFile.create(fileset)); + // use fast file to minimize system calls like length(), isDirectory(), isFile(), ... + publish(fileset.stream().map(FastFile::new).toArray(File[]::new)); } private void load(List files, boolean recursive, Collection sink) { diff --git a/source/net/filebot/ui/rename/NamesListTransferablePolicy.java b/source/net/filebot/ui/rename/NamesListTransferablePolicy.java index 3cdacff7..c2c41875 100644 --- a/source/net/filebot/ui/rename/NamesListTransferablePolicy.java +++ b/source/net/filebot/ui/rename/NamesListTransferablePolicy.java @@ -2,7 +2,6 @@ package net.filebot.ui.rename; import static java.awt.datatransfer.DataFlavor.*; import static java.util.Arrays.*; -import static java.util.Collections.*; import static net.filebot.MediaTypes.*; import static net.filebot.hash.VerificationUtilities.*; import static net.filebot.ui.transfer.FileTransferable.*; @@ -98,7 +97,7 @@ class NamesListTransferablePolicy extends FileTransferablePolicy { loadTorrentFiles(files, values); } else { // load all files from the given folders recursively up do a depth of 32 - addAll(values, FastFile.create(listFiles(files))); + listFiles(files).stream().map(FastFile::new).forEach(values::add); } model.addAll(values); diff --git a/source/net/filebot/ui/sfv/ChecksumTableModel.java b/source/net/filebot/ui/sfv/ChecksumTableModel.java index 377a6fb0..713e0c6e 100644 --- a/source/net/filebot/ui/sfv/ChecksumTableModel.java +++ b/source/net/filebot/ui/sfv/ChecksumTableModel.java @@ -182,7 +182,7 @@ class ChecksumTableModel extends AbstractTableModel { cell.addPropertyChangeListener(progressListener); if (!checksumColumns.contains(cell.getRoot())) { - checksumColumns.add(new FastFile(cell.getRoot().getPath())); + checksumColumns.add(new FastFile(cell.getRoot())); } } diff --git a/source/net/filebot/util/FastFile.java b/source/net/filebot/util/FastFile.java index 576739ed..ab8d0ada 100644 --- a/source/net/filebot/util/FastFile.java +++ b/source/net/filebot/util/FastFile.java @@ -2,7 +2,6 @@ package net.filebot.util; import java.io.File; import java.io.IOException; -import java.util.Collection; public class FastFile extends File { @@ -16,8 +15,8 @@ public class FastFile extends File { private File[] listFiles; private String canonicalPath; - public FastFile(String path) { - super(path); + public FastFile(File file) { + super(file.getPath()); } public FastFile(File parent, String child) { @@ -197,8 +196,4 @@ public class FastFile extends File { throw new UnsupportedOperationException(); } - public static FastFile[] create(Collection files) { - return files.stream().map(f -> new FastFile(f.getPath())).toArray(FastFile[]::new); - } - }