Skip to content

Alternative tail representations #20

@treeowl

Description

@treeowl

To make consecutive (unboxed) snoc and (future) unsnoc operations faster, we might consider more compact representations of the tails. In particular, we can "chunk" them if we like. Something like this:

data ListTwos a
  = Snoc2 !(ListTwos a) a a
  | Nil2

data Tail a = Tail
  { pairs :: !(ListTwos a)
  , maybeLast :: a }

The maybeLast component of the Tail is the last element if the Vector (and therefore the Tail) has an odd number of elements, and is undefined if the Vector has an even number of elements.

Of course, we could choose any small power of 2 for the chunk size, and some experimentation will be required to pick the right one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions