Is the Typed StashBuffer capacity pre-allocated?

In Akka Typed, the StashBuffer has a maximum capacity. What is the reason for this? Will increasing the capacity decrease performance, independent of the number of elements actually in the buffer?

In other words, will a StashBuffer with a capacity of 100 be faster than a StashBuffer with capacity 100000 if both buffers contain the same number of elements (eg. 99 each)?

Sometimes I don’t care about the upper bound of the buffer (just like I don’t care about the .size of a Scala List) can I just set the capacity to max. then?

It is not pre-allocated, the implementation is a linked list.

1 Like