Do 64-bit loops in QBitArray::count(bool)
On 64-bit platforms, with unaligned loads, this is defintely an improvement since we can run fewer instructions. On 32-bit platforms with unaligned loads, we'll do the exact same number of loads. On platforms without unaligned loads, it's no worse. Change-Id: Idd5dd5213975d77bbc3adf486adbf6f8ef071341 Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>bb10
parent
6f0fdaa76c
commit
6b9d125621
|
|
@ -194,7 +194,12 @@ int QBitArray::count(bool on) const
|
|||
// it's the QByteArray implicit NUL, so it will not change the bit count
|
||||
const quint8 *const end = reinterpret_cast<const quint8 *>(d.end());
|
||||
|
||||
while (bits + 3 <= end) {
|
||||
while (bits + 7 <= end) {
|
||||
quint64 v = qUnalignedLoad<quint64>(bits);
|
||||
bits += 8;
|
||||
numBits += int(qPopulationCount(v));
|
||||
}
|
||||
if (bits + 3 <= end) {
|
||||
quint32 v = qUnalignedLoad<quint32>(bits);
|
||||
bits += 4;
|
||||
numBits += int(qPopulationCount(v));
|
||||
|
|
|
|||
Loading…
Reference in New Issue