Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid making an extra call to Files.exists(p) in PathTree.ofDirectoryOrArchive(p, filter) #44453

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ static PathTree ofDirectoryOrArchive(Path p, PathFilter filter) {
try {
final BasicFileAttributes fileAttributes = Files.readAttributes(p, BasicFileAttributes.class);
return fileAttributes.isDirectory() ? new DirectoryPathTree(p, filter)
: ofArchive(p, filter);
// invoke ArchivePathTree.forPath directly instead of ofArchive() to avoid an extra Files.exists invocation
: ArchivePathTree.forPath(p, filter);
} catch (IOException e) {
throw new IllegalArgumentException(p + " does not exist", e);
}
Expand Down Expand Up @@ -76,7 +77,6 @@ static PathTree ofArchive(Path archive, PathFilter filter) {
if (!Files.exists(archive)) {
throw new IllegalArgumentException(archive + " does not exist");
}

return ArchivePathTree.forPath(archive, filter);
}

Expand Down
Loading