mirror of
https://github.com/denoland/deno.git
synced 2024-11-28 16:20:57 -05:00
perf(core): avoid creating global handles in op_queue_microtask
(#16359)
This commit is contained in:
parent
e2be70b035
commit
d3736f12b5
1 changed files with 9 additions and 3 deletions
|
@ -64,6 +64,14 @@ fn to_v8_fn(
|
||||||
.map_err(|err| type_error(err.to_string()))
|
.map_err(|err| type_error(err.to_string()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn to_v8_local_fn(
|
||||||
|
value: serde_v8::Value,
|
||||||
|
) -> Result<v8::Local<v8::Function>, Error> {
|
||||||
|
v8::Local::<v8::Function>::try_from(value.v8_value)
|
||||||
|
.map_err(|err| type_error(err.to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
#[op(v8)]
|
#[op(v8)]
|
||||||
fn op_ref_op(scope: &mut v8::HandleScope, promise_id: i32) {
|
fn op_ref_op(scope: &mut v8::HandleScope, promise_id: i32) {
|
||||||
let context_state = JsRealm::state_from_scope(scope);
|
let context_state = JsRealm::state_from_scope(scope);
|
||||||
|
@ -196,9 +204,7 @@ fn op_queue_microtask(
|
||||||
scope: &mut v8::HandleScope,
|
scope: &mut v8::HandleScope,
|
||||||
cb: serde_v8::Value,
|
cb: serde_v8::Value,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let cb = to_v8_fn(scope, cb)?;
|
scope.enqueue_microtask(to_v8_local_fn(cb)?);
|
||||||
let cb = v8::Local::new(scope, cb);
|
|
||||||
scope.enqueue_microtask(cb);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue