composewell / streamly

High performance, concurrent functional programming abstractions
https://streamly.composewell.com
Other
857 stars 64 forks source link

Use resizeMutableByteArray# and shrinkMutableByteArray# to resize MutArray #2551

Closed harendra-kumar closed 1 year ago

harendra-kumar commented 1 year ago

Currently we implement realloc by allocating a new array and copying the old array into it.

rnjtranjan commented 1 year ago

As per docs it works for unpinned mutable byte array only. In our code it works for pinned and unpinned both.

harendra-kumar commented 1 year ago

We already reuse the old array when we truncate up to a certain threshold, so we can continue using the existing code.