Skip to content

Shrink small mutable array

Implement shrinkSmallMutableArray# and resizeSmallMutableArray#. I would appreciate any feedback. ccing @hvr, since you implemented shrinkMutableByteArray# and @treeowl, since you wrote the proposal that this is an implementation of. The rest of this is just a copy of the git commit.

This is a part of GHC Proposal #25 (closed): "Offer more array resizing primitives". Resources related to the proposal:

Only shrinkSmallMutableArray# is implemented as a primop since a library-space implementation of resizeSmallMutableArray# (in GHC.Exts) is no less efficient than a primop would be. This may be replaced by a primop in the future if someone devises a strategy for growing arrays in-place. The library-space implementation always copies the array when growing it.

Additionally, this commit tweaks the documentation of the deprecated sizeofMutableByteArray#, removing the mention of concurrency. That primop is unsound even in single-threaded applications.

Merge request reports