Skip to content

Commit

Permalink
perf(core): use opcall() directly (denoland#12310)
Browse files Browse the repository at this point in the history
Instead of the wrapper dispatch() func, also now forbids passing opIds to opSync()/opAsync() callers must always pass names
  • Loading branch information
AaronO authored Oct 3, 2021
1 parent 2170a41 commit 11acdf1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
9 changes: 2 additions & 7 deletions core/01_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@
}
}

function dispatch(opName, promiseId, control, zeroCopy) {
const opId = typeof opName === "string" ? opsCache[opName] : opName;
return opcall(opId, promiseId, control, zeroCopy);
}

function registerErrorClass(className, errorClass) {
registerErrorBuilder(className, (msg) => new errorClass(msg));
}
Expand Down Expand Up @@ -130,14 +125,14 @@

function opAsync(opName, arg1 = null, arg2 = null) {
const promiseId = nextPromiseId++;
const maybeError = dispatch(opName, promiseId, arg1, arg2);
const maybeError = opcall(opsCache[opName], promiseId, arg1, arg2);
// Handle sync error (e.g: error parsing args)
if (maybeError) return unwrapOpResult(maybeError);
return PromisePrototypeThen(setPromise(promiseId), unwrapOpResult);
}

function opSync(opName, arg1 = null, arg2 = null) {
return unwrapOpResult(dispatch(opName, null, arg1, arg2));
return unwrapOpResult(opcall(opsCache[opName], null, arg1, arg2));
}

function resources() {
Expand Down
2 changes: 1 addition & 1 deletion core/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1848,7 +1848,7 @@ pub mod tests {
r#"
let thrown;
try {
Deno.core.opSync(100);
Deno.core.opcall(100, null, null, null);
} catch (e) {
thrown = e;
}
Expand Down

0 comments on commit 11acdf1

Please sign in to comment.