samtools / htsjdk

A Java API for high-throughput sequencing data (HTS) formats.
http://samtools.github.io/htsjdk/
283 stars 242 forks source link

AbstractLocusIterator uses a ArrayList but uses it like a queue #1490

Open yfarjoun opened 4 years ago

yfarjoun commented 4 years ago

The accumulator field is used with the following access patterns:

as one can see, except for the last item, these would all be better implemented using a Deque, but the random access isn't supported by a deque. I think it would be good to profile performance and observe how much compute is used in the accumulator .remove(0) and .add(0) calls, and if it's not insignificant, implement a Deque that has random access and use it.