diff options
Diffstat (limited to 'src/isolate.rs')
-rw-r--r-- | src/isolate.rs | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/src/isolate.rs b/src/isolate.rs index 6e4c421c7..a9088e708 100644 --- a/src/isolate.rs +++ b/src/isolate.rs @@ -190,15 +190,14 @@ impl Isolate { pub fn respond(&mut self, req_id: i32, buf: Buf) { self.state.metrics_op_completed(buf.len()); - - // TODO(zero-copy) Use Buf::leak(buf) to leak the heap allocated buf. And - // don't do the memcpy in ImportBuf() (in libdeno/binding.cc) + // deno_respond will memcpy the buf into V8's heap, + // so borrowing a reference here is sufficient. unsafe { libdeno::deno_respond( self.libdeno_isolate, self.as_void_ptr(), req_id, - buf.into(), + buf.as_ref().into(), ) } } @@ -271,20 +270,6 @@ impl Drop for Isolate { } } -/// Converts Rust Buf to libdeno `deno_buf`. -impl From<Buf> for libdeno::deno_buf { - fn from(x: Buf) -> Self { - let len = x.len(); - let ptr = Box::into_raw(x); - Self { - alloc_ptr: std::ptr::null_mut(), - alloc_len: 0, - data_ptr: ptr as *mut u8, - data_len: len, - } - } -} - // Dereferences the C pointer into the Rust Isolate object. extern "C" fn pre_dispatch( user_data: *mut c_void, |