Is there any optimization like NSFastEnumeration (batch fetching, detecting mutations) in Swift? SequenceType doesn’t seem to do that.
-
-
@mjtsai As I understand it, it doesn’t necessarily have to send a message. It may not even need indirection through a vtable. - View other replies
-
@mjtsai And if it’s dispatched statically it can be inlined. - View other replies
-
@rob_rix Wonder how often that is. I would think you’re usually passed in a collection and don’t know its type. -
@mjtsai Technically that _can_ be specialized at compile time (and IIRC the compiler has begun to in some cases). -
@rob_rix How can you do that if the sequence you receive is not final? -
@mjtsai Given func f<C: SequenceType>(c:C){ …loop over c… }, compile f_Array & f_Set, dispatch at call to f instead of within the loop. -
@rob_rix So it doesn't work if f takes an array instead of a SequenceType? -
@mjtsai Yeah you’d have to have a generic fallback for when the thing calling the generic thing is itself generic. Diminishing returns! - Show more
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
Michael Tsai
Rob Rix