Skip to content

perf: exists and readAttributesIfExists without exceptions - #98

Open
andreaTP wants to merge 1 commit into
mainfrom
perf/exists-without-exceptions
Open

andreaTP wants to merge 1 commit into
mainfrom
perf/exists-without-exceptions

Conversation

@andreaTP

Copy link
Copy Markdown

On JDK 20+ Files.exists/isDirectory/isRegularFile call FileSystemProvider.exists/readAttributesIfExists; the inherited defaults throw and catch NoSuchFileException for every missing file. Overriding them (no @Override, still compiles for Java 11) avoids the exception.

existsMissing: 1297 -> 39 ns/op (JDK 21, benchmark from #97).

Checked with Endive (wasi-tests, machine-tests, wabt, Zig stdlib suite): no regressions.

On JDK 20+ Files.exists, isDirectory and isRegularFile call these provider
methods; the inherited defaults threw and caught NoSuchFileException for
every missing file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant