Re:Fast memcpy, A System Design
by georgelyon on Monday December 19, 2022 @08:41PM
(#34060451)
While the overall point is valid, this isn’t strictly true. A Swift string is frequently backed by a contiguous UTC8 buffer terminated with a \0, so passing to C is just a matter of passing the pointer and requires no copies.
[ Parent
| on HN ]
But Swift has no way of signaling to C that the memory can be freed so I’m pretty sure it does a copy when using String’s cString constructor.