perf(runtime): optimize Deno.file open & stream (#15496)

This commit is contained in:
Divy Srivastava 2022-08-19 15:54:40 +05:30 committed by GitHub
parent 8bdcec1c84
commit 9e576dff7c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 82 additions and 35 deletions

View file

@ -33,12 +33,14 @@
function openSync(
path,
options = { read: true },
options,
) {
checkOpenOptions(options);
if (options) checkOpenOptions(options);
const mode = options?.mode;
const rid = ops.op_open_sync(
{ path: pathFromURL(path), options, mode },
pathFromURL(path),
options,
mode,
);
return new FsFile(rid);
@ -46,13 +48,15 @@
async function open(
path,
options = { read: true },
options,
) {
checkOpenOptions(options);
if (options) checkOpenOptions(options);
const mode = options?.mode;
const rid = await core.opAsync(
"op_open_async",
{ path: pathFromURL(path), options, mode },
pathFromURL(path),
options,
mode,
);
return new FsFile(rid);