Memcpy()ing into a slice of cells

Simple API:

impl<T: Copy> [Cell<T>] {
  fn copy_cells_from_slice(&self, src: &[T]);

Maybe also a version that takes src: &[Cell<T>]? Notionally this would just call set() on every element, but compile down a memcpy. Thoughts?


.set() on every element in a loop already optimizes to memcpy:

I mean yes, LLVM is smart. But we have copy_from_slice, might as well advertise a well-lit path for safely-aliased mutation of byte buffers.

(This is how you wind up with people using ptr::copy_nonoverlapping because they think the for loop won't work. This isn't speculation, kernel programmers absolutely do this.)


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.