# HG changeset patch # User cushon # Date 1546997877 28800 # Node ID 716c746165b2b8be1738236221f754937a179391 # Parent bccff579c2ff05a1e1035028f880df6c4c6fad5e 8216403: Allocate fewer EnumSets in JavacFileManager#list Reviewed-by: vromero, redestad diff -r bccff579c2ff -r 716c746165b2 src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java Wed Jan 09 20:28:16 2019 +0100 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java Tue Jan 08 17:37:57 2019 -0800 @@ -104,8 +104,8 @@ private FSInfo fsInfo; - private final Set sourceOrClass = - EnumSet.of(JavaFileObject.Kind.SOURCE, JavaFileObject.Kind.CLASS); + private static final Set SOURCE_OR_CLASS = + Set.of(JavaFileObject.Kind.SOURCE, JavaFileObject.Kind.CLASS); protected boolean symbolFileEnabled; @@ -500,6 +500,9 @@ } } + private static final Set NO_FILE_VISIT_OPTIONS = Set.of(); + private static final Set FOLLOW_LINKS_OPTIONS = Set.of(FOLLOW_LINKS); + private final class ArchiveContainer implements Container { private final Path archivePath; private final FileSystem fileSystem; @@ -517,7 +520,7 @@ } packages = new HashMap<>(); for (Path root : fileSystem.getRootDirectories()) { - Files.walkFileTree(root, EnumSet.noneOf(FileVisitOption.class), Integer.MAX_VALUE, + Files.walkFileTree(root, NO_FILE_VISIT_OPTIONS, Integer.MAX_VALUE, new SimpleFileVisitor() { @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) { @@ -548,8 +551,7 @@ return ; int maxDepth = (recurse ? Integer.MAX_VALUE : 1); - Set opts = EnumSet.of(FOLLOW_LINKS); - Files.walkFileTree(resolvedSubdirectory, opts, maxDepth, + Files.walkFileTree(resolvedSubdirectory, FOLLOW_LINKS_OPTIONS, maxDepth, new SimpleFileVisitor() { @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) { @@ -763,7 +765,7 @@ // validateClassName(className); nullCheck(className); nullCheck(kind); - if (!sourceOrClass.contains(kind)) + if (!SOURCE_OR_CLASS.contains(kind)) throw new IllegalArgumentException("Invalid kind: " + kind); return getFileForInput(location, RelativeFile.forClass(className, kind)); } @@ -811,7 +813,7 @@ // validateClassName(className); nullCheck(className); nullCheck(kind); - if (!sourceOrClass.contains(kind)) + if (!SOURCE_OR_CLASS.contains(kind)) throw new IllegalArgumentException("Invalid kind: " + kind); return getFileForOutput(location, RelativeFile.forClass(className, kind), sibling); }