[swift-evolution] [Pitch] Move UnsafeMutablePointer.initialize(from:) to UnsafeMutableBufferPointer
xiaodi.wu at gmail.com
Wed Dec 7 20:32:34 CST 2016
This proposal seems well thought-out to me; +1 as well.
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
On Wed, Dec 7, 2016 at 5:32 PM, Andrew Trick via swift-evolution <
swift-evolution at swift.org> wrote:
> On Nov 30, 2016, at 4:48 PM, Ben Cohen via swift-evolution <
> swift-evolution at swift.org> 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
> (they need a bit of performance work before they’re ready to land)
> 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
> +1 on this proposal.
> (looks like I had forgotten to reply to the list)
> swift-evolution mailing list
> swift-evolution at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution