I'm suggesting a set of improvements for BitSets implementation .
Current one is using a bit access (get/set) in for loops for bulk operations (like invert()).
New implementation perform bulk operation on bytes with proper mask. Also get/set performance is improved with lookup tables.
Calculations of i / 8 and i % 8 are replaced with equal i >> 3 and i & 7.
BitCount lookup table declaration has been replaced with its macro compacted variant taken from Bit Twiddling Hacks. It's moved to header as now it's used in BitSet::set too.
Note: as BitSet::get/BitSet::set are inlined - you need to recompile KTorrent too to benefit from their implementations
There are no specific tests for BitSet, but it's used in utppolltest at least