This proposal seems well thought-out to me; +1 as well. Nits:
It seems the more natural order for the return value might be `(initializedUpTo: Index, unwritten: S.Iterator)`, since after all the call site is spelled `receiver.initialize(from: source)`. Also, I'd suggest having the label as `initializedUpTo` (rather than `initialized`) in the tuple return value for `UnsafeMutableRawBufferPointer.initialize(as:from:)` as well; if I understand correctly, it's supposed to be an UnsafeRawBufferPointer that points past the last byte written, so the pointee itself isn't actually initialized. (Plus, `initialized` could equally convey the unintended idea that the UnsafeRawBufferPointer points to the first of the initialized bytes.) On Wed, Dec 7, 2016 at 5:32 PM, Andrew Trick via swift-evolution < [email protected]> wrote: > > On Nov 30, 2016, at 4:48 PM, Ben Cohen via swift-evolution < > [email protected]> wrote: > > > Hi swift-evolution, > > Below is a draft proposal for a change to facilitate fixing some memory > safety issues in the standard library. > > If you’re interested in the implementation, PRs can be found here: [stdlib] > [WIP] Eliminate version of Array.append(contentsOf:) that takes a Collection > <https://github.com/apple/swift/pull/5521> and here: [stdlib] [WIP] Add > UnsafeRawBufferPointer.initialize(as:from:) > <https://github.com/apple/swift/pull/5718> > (they need a bit of performance work before they’re ready to land) > > Introduction > > The version of UnsafeMutablePointer.initialize(from:) that takes a > Collection should be deprecated in favour of a new method on > UnsafeMutableBufferPointer that takes a Sequence, with a goal of > improving memory safety and enabling faster initialization of memory from > sequences. Similarly, UnsafeMutableRawPointer.initializeMemory(as:from:) > should > be deprecated in favour of a new UnsafeMutableRawBufferPoin > ter.initialize(as:from:). > > <https://github.com/airspeedswift/swift-evolution/blob/b1d05032567e5c7b469f3ccca1bc1a42175a2400/proposals/NNNN-move-unsafe-initialize-from.md#motivation> > > > +1 on this proposal. > > (looks like I had forgotten to reply to the list) > > -Andy > > _______________________________________________ > swift-evolution mailing list > [email protected] > https://lists.swift.org/mailman/listinfo/swift-evolution > >
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
