On Sep 12, 2016, at 10:16 , Jens Alfke <j...@mooseyard.com> wrote:
> 
> The question in my mind is whether the array struct ever gets copied in this 
> code — it’s not explicitly passed as a parameter, just closed over. I don’t 
> think I’ve read any docs that describe explicitly what the behavior is, maybe 
> because it only becomes significant when you introduce threads?

The array is going to get copied at least once, because it’s a local variable 
captured by a block. That means it needs to be copied to the heap.

> This situation also begs the question of what kind of lower-level data 
> structure one can use in Swift when Array is too high-level. In Obj-C one can 
> drop down to C arrays, for example.

My understanding is that pure Swift arrays (that is, *not* bridged NSArrays) 
are stored as efficiently as C arrays.

However, in this particular example, the array, a mutable structure, is 
modified unsafely from multiple threads. That may or may not be the cause of 
the crash, but it’s certainly a bug that should be fixed first.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to