Skip to content

Commit

Permalink
Merge pull request #44453 from aloubyansky/path-tree-exists
Browse files Browse the repository at this point in the history
Avoid making an extra call to Files.exists(p) in PathTree.ofDirectoryOrArchive(p, filter)
  • Loading branch information
gsmet authored Nov 13, 2024
2 parents 0c5417f + b2e479d commit 7684fbd
Showing 1 changed file with 2 additions and 2 deletions.
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

0 comments on commit 7684fbd

Please sign in to comment.