mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
perf(fs): don't canonicalize path when opening file if --allow-all
is passed (#28716)
Fixes #28702. Super artificial benchmark: ```ts const perf = performance; async function asyncOpen() { const start = perf.now(); for (let i = 0; i < 100_000; i++) { const file = await Deno.open("./foo.txt"); file.close(); } const end = perf.now(); console.log(end - start); } function syncOpen() { const start = perf.now(); for (let i = 0; i < 100_000; i++) { const file = Deno.openSync("./foo.txt"); file.close(); } const end = perf.now(); console.log(end - start); } if (Deno.args[0]?.trim() === "async") { await asyncOpen(); } else { syncOpen(); } ``` Results (average of 10 for each): ``` deno sync 1785.59 deno-this-pr sync 491.69 deno async 1839.71 deno-this-pr async 528.78 ``` --------- Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
This commit is contained in:
parent
1a171f10df
commit
c22d17824b
14 changed files with 205 additions and 134 deletions
|
@ -61,7 +61,7 @@ impl<TSys: DenoLibSys> NpmRegistryReadPermissionChecker<TSys> {
|
|||
Ok(Cow::Borrowed(path))
|
||||
} else {
|
||||
permissions
|
||||
.check_read_path(path)
|
||||
.check_read_path(Cow::Borrowed(path))
|
||||
.map_err(JsErrorBox::from_err)
|
||||
}
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ impl<TSys: DenoLibSys> NpmRegistryReadPermissionChecker<TSys> {
|
|||
}
|
||||
|
||||
permissions
|
||||
.check_read_path(path)
|
||||
.check_read_path(Cow::Borrowed(path))
|
||||
.map_err(JsErrorBox::from_err)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue