> On Jan 24, 2017, at 11:22 AM, Dave Abrahams via swift-evolution > <[email protected]> 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 Architechies _______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
