The previous implementation (the legacy one) used linked lists for this. It's better as complexity go but it's not that good taking in account CPU cache. In any case, the current implementation I think it's good enough. If this gets merged, I'll try different variants on the data structure and do some performance analysis to get the best one.