travitch / persistent-vector

Persistent vectors for Haskell based on array mapped tries
BSD 3-Clause "New" or "Revised" License
27 stars 4 forks source link

Make slow things less slow #34

Open treeowl opened 4 years ago

treeowl commented 4 years ago

It's a bit annoying that drop and append allocate intermediate lists of individual elements. We can break up a vector (or part of one) into a type like this:

data Blobs a
  = ConsBlob !(Array a) (Blobs a)
  | EndBlobs ![a]

Now we can walk a Blobs list two chunks at a time to realign it. This is expensive, but it should be much less expensive than working through lists of elements.