1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 15:24:46 -05:00

perf(core): use opcall() directly (#12310)

Instead of the wrapper dispatch() func, also now forbids passing opIds to opSync()/opAsync() callers must always pass names
This commit is contained in:
Aaron O'Mullan 2021-10-03 21:02:50 +02:00 committed by GitHub
parent 2170a41d97
commit 11acdf1ea8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 8 deletions

View file

@ -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));
}
@ -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() {

View file

@ -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;
}