mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
file util: don't load a traverser until it's needed
GitOrigin-RevId: 9e7ab9650008d8e0272bf178b73f6f4e173c274c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
cea97b4ca4
commit
7a5801c70c
@@ -7,7 +7,6 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.util.text.StringUtilRt;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.concurrency.FixedFuture;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -1088,13 +1087,15 @@ public class FileUtil extends FileUtilRt {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JBTreeTraverser<File> fileTraverser(@Nullable File root) {
|
||||
return FILE_TRAVERSER.withRoot(root);
|
||||
private static class Lazy {
|
||||
private static final JBTreeTraverser<File> FILE_TRAVERSER = JBTreeTraverser.from(
|
||||
(Function<File, Iterable<File>>)file -> file == null ? Collections.emptySet() : JBIterable.of(file.listFiles()));
|
||||
}
|
||||
|
||||
private static final JBTreeTraverser<File> FILE_TRAVERSER = JBTreeTraverser.from(
|
||||
(Function<File, Iterable<File>>)file -> file == null ? Collections.emptySet() : JBIterable.of(file.listFiles()));
|
||||
@NotNull
|
||||
public static JBTreeTraverser<File> fileTraverser(@Nullable File root) {
|
||||
return Lazy.FILE_TRAVERSER.withRoot(root);
|
||||
}
|
||||
|
||||
public static boolean processFilesRecursively(@NotNull File root, @NotNull Processor<? super File> processor) {
|
||||
return fileTraverser(root).bfsTraversal().processEach(processor);
|
||||
|
||||
Reference in New Issue
Block a user