Reactive-Extensions/Rx.rb — pull request #14 by brainopia (2014-02-19 00:27:01+00:00)
Title: Remove capacity planning for priority queue

https://gist.github.com/brainopia/221b252ab4864327fb27 — I've tried to demonstrate that using dynamically growing array in priority queue has no noticeable overhead.

MRI has several optimizations regarding array capacity. It will by default embed up to 3 elements into array object memory layout (in next MRI version it may increase) afterwards it will use a separate heap storage allocating each time two times more space when reaching a limit.

It sounds non-optimal to fallback to default behavior if we can preallocate the space we need in one action, but overhead of pushing and percolating a new element to priority queue is much bigger.

Having choice between two equally performing options the simpler one is preferable.