Is there any optimization like NSFastEnumeration (batch fetching, detecting mutations) in Swift? SequenceType doesn’t seem to do that.
-
-
@mjtsai The generator can batch & detect mutations. Often it’ll live on the stack, so .next() is not much worse than incrementing the ptr. - View other replies
-
@rob_rix that slow or that the batching isn’t that worth it. -
@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. - 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