Optimize non-overlapping copy in raw_data (#583)

master
Niklas Fiekas 3 years ago committed by GitHub
parent 8bf9faddb3
commit c482c625ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/ffi_util.rs

@ -29,8 +29,8 @@ pub(crate) unsafe fn raw_data(ptr: *const c_char, size: usize) -> Option<Vec<u8>
None
} else {
let mut dst = Vec::with_capacity(size);
ptr::copy_nonoverlapping(ptr as *const u8, dst.as_mut_ptr(), size);
dst.set_len(size);
ptr::copy(ptr as *const u8, dst.as_mut_ptr(), size);
Some(dst)
}
}

Loading…
Cancel
Save