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.
It's a bit annoying that
drop
andappend
allocate intermediate lists of individual elements. We can break up a vector (or part of one) into a type like this: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.