diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-12-04 16:05:40 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-04 21:05:40 +0000 |
commit | a24d3e8763bc48b69936db9231efb76766914303 (patch) | |
tree | 7091c5354d1e341c34e5847ea0271213c8730c69 /ext/node/polyfills/_fs | |
parent | 9eb25e3cff22d1f704ede0d4066abc846a26a919 (diff) |
perf(node/fs): faster `existsSync` when not exists (#21458)
Diffstat (limited to 'ext/node/polyfills/_fs')
-rw-r--r-- | ext/node/polyfills/_fs/_fs_exists.ts | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/ext/node/polyfills/_fs/_fs_exists.ts b/ext/node/polyfills/_fs/_fs_exists.ts index 9c8458b58..db41aedec 100644 --- a/ext/node/polyfills/_fs/_fs_exists.ts +++ b/ext/node/polyfills/_fs/_fs_exists.ts @@ -2,7 +2,7 @@ // TODO(petamoriken): enable prefer-primordials for node polyfills // deno-lint-ignore-file prefer-primordials - +const core = globalThis.__bootstrap.core; import { pathFromURL } from "ext:deno_web/00_infra.js"; type ExistsCallback = (exists: boolean) => void; @@ -35,10 +35,5 @@ Object.defineProperty(exists, kCustomPromisifiedSymbol, { */ export function existsSync(path: string | URL): boolean { path = path instanceof URL ? pathFromURL(path) : path; - try { - Deno.lstatSync(path); - return true; - } catch (_err) { - return false; - } + return core.ops.op_node_fs_exists_sync(path); } |