diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2022-09-19 20:43:34 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-19 20:43:34 +0530 |
commit | 38649613644aa46ac927b8b17ea07f2cc9d1b5ef (patch) | |
tree | 19b20248a8257dd610c321a6f94376a06154163c | |
parent | 1464b756a4ef091ef97d1bf7340188ab5fe5492a (diff) |
perf(core): use single ObjectTemplate for ops in `initialize_ops` (#15959)
-rw-r--r-- | core/bindings.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/core/bindings.rs b/core/bindings.rs index 7f4a0ebd9..3d7a7098a 100644 --- a/core/bindings.rs +++ b/core/bindings.rs @@ -140,17 +140,17 @@ fn initialize_ops( op_ctxs: &[OpCtx], snapshot_loaded: bool, ) { + let object_template = v8::ObjectTemplate::new(scope); + assert!(object_template.set_internal_field_count( + (crate::runtime::V8_WRAPPER_OBJECT_INDEX + 1) as usize + )); + for ctx in op_ctxs { let ctx_ptr = ctx as *const OpCtx as *const c_void; // If this is a fast op, we don't want it to be in the snapshot. // Only initialize once snapshot is loaded. if ctx.decl.fast_fn.is_some() && snapshot_loaded { - let object_template = v8::ObjectTemplate::new(scope); - assert!(object_template.set_internal_field_count( - (crate::runtime::V8_WRAPPER_OBJECT_INDEX + 1) as usize - )); - let method_obj = object_template.new_instance(scope).unwrap(); method_obj.set_aligned_pointer_in_internal_field( crate::runtime::V8_WRAPPER_OBJECT_INDEX, |