[swift-dev] [idle] COW wrapper in 30 lines
jordan_rose at apple.com
Wed Mar 9 11:53:35 CST 2016
Ha, I remember this document, but forgot it included an implementation. Encouraging to see that it's pretty much identical.
The concrete type forwarding logic is something we ought to be able to simplify somehow (with new language features).
> On Mar 9, 2016, at 9:50 , Nadav Rotem <nrotem at apple.com> wrote:
> HI Jordan,
> Very Nice!
> There is a similar implementation and discussion about performance here:
> https://github.com/apple/swift/blob/master/docs/OptimizationTips.rst#advice-use-copy-on-write-semantics-for-large-values <https://github.com/apple/swift/blob/master/docs/OptimizationTips.rst#advice-use-copy-on-write-semantics-for-large-values>
>> On Mar 9, 2016, at 9:39 AM, Jordan Rose via swift-dev <swift-dev at swift.org> wrote:
>> Just for fun, I wrote a wrapper for COW types that don't need the flexible inline storage of ManagedBuffer. It turned out to be pretty straightforward, though I didn't bother with materializeForSet and thus am incurring the cost of many extra value copies on mutation. The major downside is having to forward all operations through, something I'm sure the implementers of Array and Dictionary are very used to!
>> Disclaimer: This is not performant; don't use it in your app.
>> swift-dev mailing list
>> swift-dev at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-dev