|
|
|
|
|
by nmilo
1004 days ago
|
|
There should be a from_raw_parts-like interface for Arc that can construct one out of a pointer to a T + control block. That way you can shift the string data over and stick the control block inline (which is how I assume it's laid out in memory) and convert String to Arc<str> for free (well not free, shifting takes O(n), but so does the copying in Arc::new, so in the end you do end up avoiding an allocation for free) |
|
(And the control block really does need to be aligned, since otherwise we couldn't perform atomic operations on it.)