[swift-dev] [idle] COW wrapper in 30 lines

Jordan Rose jordan_rose at apple.com
Wed Mar 9 11:39:15 CST 2016


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.

Jordan


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20160309/a06669fb/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cow.swift
Type: application/octet-stream
Size: 982 bytes
Desc: not available
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20160309/a06669fb/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20160309/a06669fb/attachment-0001.html>


More information about the swift-dev mailing list