in reply to Efficiency Question

Did you look at Circular buffer instead of shift/push? It can save the O(n) operations you have.