Open
Description
The problem is that withUnsafeMutableBufferPointer
forces a copy if the storage is not uniquely referenced. If you are going to then rewrite/move a significant number of elements, the original copies are wasted effort, which could be bad for locality. What you really want in those cases is to construct the new buffer in its final form in-situ. This is just something to consider/benchmark as you look to further optimize. Starting with the current strategy certainly makes sense.