On Aug 20, 2014, at 20:32 , Gerriet M. Denkmann <[email protected]> wrote:
> But I thought that maybe memmove might be more efficient: > > let dest : UnsafeMutablePointer<Void> = arr + lowerIndex + 1 Er, no. There are multiple things wrong with this: — There’s nothing in the Swift array API contract that says that elements are stored in a contiguous block of memory, or even in several blocks of memory — Even if they were, there’s nothing that says how they’re laid out in that memory — Even if there was, there’s nothing that gives you access to that memory (well, AFAIK) — Even if there was, the use of ‘arr’ as a pointer to the start of the memory is a C-ism, and doesn’t apply to an array variable in Swift. If you want to do this sort of thing, you’re going to have to cause your own block of memory to be allocated (e.g. in a NSData object). Alternatively, you could code the move as you originally did, and trust that at some point the Swift compiler will understand what you’re doing and optimize it for you. _______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
