[swift-evolution] Strings in Swift 4

Brent Royal-Gordon brent at architechies.com
Tue Jan 24 22:22:41 CST 2017

> On Jan 24, 2017, at 11:22 AM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
>> How important is that, though? If you're using a `Substring`, you
>> expect to keep the top-level `String` around and probably continue
>> sharing storage with it, so you're probably extending its lifetime
>> anyway. Or are you thinking of this as a speed optimization, rather
>> than a memory optimization?
> It's both.  It's true that it will rarely save space, but sometimes it
> will.  More importantly perhaps, it eliminates ARC traffic.

I'll probably reply to more of this later, but I had a random shower thought I wanted to share:

Could we build this capability into `Slice` so that any collection (or at least any collection which conforms to the right, probably stdlib-internal, protocol) could pack data directly into the instance instead of holding a reference to the base collection? Obviously only collections holding trivial types could do it, but I could see that being a useful general optimization.

Brent Royal-Gordon

More information about the swift-evolution mailing list