Skip to content

InlineOrHeap sequence #484

@MahdiBM

Description

@MahdiBM

We should have an InlineOrHeap sequence/collection that uses an InlineArray to some extent, and more than that it allocates on heap.

This will avoid allocating on heap when there are not enough values to justify so.
This can be pretty useful in performance-sensitive code.

Something along the lines of:

enum InlineOrHeap<let count: Int, Element> {
    case inline(InlineArray<count, Element>)
    case heap(Array<Element>)
}

Usage:

let tinyValue: InlineOrHeap<8, Int> = ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions