The implementation of Collection.map can be found here: 
https://github.com/apple/swift/blob/master/stdlib/public/core/Collection.swift#L1265-L1286

It uses repeated subscripts, rather than `makeIterator()`. Isn’t this a 
problem? I overloaded `makeIterator` on a custom collection once (I think it 
was a binary tree) because an iterator would be able to iterate the collection 
more efficiently than subscripts would (both O(n), but with a lower constant 
factor). If `makeIterator` isn’t overloaded, then subscripts are used anyways 
(by `IndexingIterator`). Wouldn’t it make more sense to use an iterator in 
Collection.map instead, in order to benefit from a possibly more efficient 
iterator than the default one?
_______________________________________________
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev

Reply via email to