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
|
@ -102,11 +102,11 @@ where
|
|||
.borrow_mut::<NP>()
|
||||
.check_read(&address_path, "Deno.connect()")
|
||||
.map_err(NetError::Permission)?;
|
||||
_ = state_
|
||||
|
||||
state_
|
||||
.borrow_mut::<NP>()
|
||||
.check_write_path(&address_path, "Deno.connect()")
|
||||
.map_err(NetError::Permission)?;
|
||||
address_path
|
||||
.check_write_path(Cow::Owned(address_path), "Deno.connect()")
|
||||
.map_err(NetError::Permission)?
|
||||
};
|
||||
let unix_stream = UnixStream::connect(&address_path).await?;
|
||||
let local_addr = unix_stream.local_addr()?;
|
||||
|
@ -188,8 +188,8 @@ where
|
|||
let address_path = permissions
|
||||
.check_read(&address_path, &api_call_expr)
|
||||
.map_err(NetError::Permission)?;
|
||||
_ = permissions
|
||||
.check_write_path(&address_path, &api_call_expr)
|
||||
let address_path = permissions
|
||||
.check_write_path(Cow::Owned(address_path), &api_call_expr)
|
||||
.map_err(NetError::Permission)?;
|
||||
let listener = UnixListener::bind(address_path)?;
|
||||
let local_addr = listener.local_addr()?;
|
||||
|
@ -210,8 +210,8 @@ where
|
|||
let address_path = permissions
|
||||
.check_read(&address_path, "Deno.listenDatagram()")
|
||||
.map_err(NetError::Permission)?;
|
||||
_ = permissions
|
||||
.check_write_path(&address_path, "Deno.listenDatagram()")
|
||||
let address_path = permissions
|
||||
.check_write_path(Cow::Owned(address_path), "Deno.listenDatagram()")
|
||||
.map_err(NetError::Permission)?;
|
||||
let socket = UnixDatagram::bind(address_path)?;
|
||||
let local_addr = socket.local_addr()?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue