Improve performance of circular buffer.