This pull request optimizes the chunk selector search algorithm. It allows only searching the bitfield for the piece priority type we're looking for. Support is added to the download delegator to support this optimized search algorithm. The download delegator is also optimized to avoid searching the bitfield for normal priority pieces, when high priority pieces are found.
The result is a reduction in CPU usage when downloading torrents and an increase in the maximum download speed ceiling. Furthermore, high priority files are also downloaded quicker, with less normal priority pieces in the download queue.
This pull request optimizes the chunk selector search algorithm. It allows only searching the bitfield for the piece priority type we're looking for. Support is added to the download delegator to support this optimized search algorithm. The download delegator is also optimized to avoid searching the bitfield for normal priority pieces, when high priority pieces are found.
The result is a reduction in CPU usage when downloading torrents and an increase in the maximum download speed ceiling. Furthermore, high priority files are also downloaded quicker, with less normal priority pieces in the download queue.