From a24d3e8763bc48b69936db9231efb76766914303 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Mon, 4 Dec 2023 16:05:40 -0500 Subject: perf(node/fs): faster `existsSync` when not exists (#21458) --- ext/node/polyfills/_fs/_fs_exists.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'ext/node/polyfills/_fs') 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); } -- cgit v1.2.3