[swift-evolution] [swift-users] How does "Sequence.joined" work?

Taylor Swift kelvin13ma at gmail.com
Wed Aug 9 11:08:09 CDT 2017


On Wed, Aug 9, 2017 at 5:54 AM, Daniel Vollmer via swift-evolution <
swift-evolution at swift.org> wrote:

>
> > On 9. Aug 2017, at 06:51, Taylor Swift via swift-users <
> swift-users at swift.org> wrote:
> >
> > It’s possible to implement a classic red-black tree in Swift that
> performs better than a sorted Array, down to about n = 1,500 items, not n =
> 100,000 items as it claims. (Actually, heap allocators these days are good
> enough that performance is on par with Array all the way down to n = 1.)
>
> I’m not sure how that can be because you lose locality (but that probably
> depends on what operations “perform” includes). And IMO, heap allocations
> remain (and will remain) a bottleneck for small allocations.
>
>         Daniel.
> _______________________________________________
>
>
If the number of nodes is small, Swift’s heap allocator will actually place
then contiguously in memory, just like an Array, as long as you don’t wait
too long between calls to insert(_:). You can also write your own simple
memory allocator in Swift that’s backed by an Array which guarantees the
nodes will live near each other in memory. But that’s getting off topic lol
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170809/a28a050d/attachment.html>


More information about the swift-evolution mailing list