diff options
| author | Liang Qi <liang.qi@qt.io> | 2016-05-26 09:40:39 +0200 |
|---|---|---|
| committer | Paul Olav Tvete <paul.tvete@theqtcompany.com> | 2016-05-26 13:04:32 +0200 |
| commit | 2fb026d58b45f50ed7d5666de58c9184e81bbc60 (patch) | |
| tree | ad1a80d7e2579899c55fce7771472a7d9176af0e /src/corelib/tools/qbitarray.cpp | |
| parent | 184b2ea4ea9c3e4ad735ff67c5a399e9613da8ab (diff) | |
| parent | 540978288ea0f6ed0b166bb9207f427a4c825ab6 (diff) | |
Merge remote-tracking branch 'origin/5.6.1' into 5.7.0
Conflicts:
src/corelib/tools/qsimd_p.h
src/network/socket/qnativesocketengine_winrt.cpp
Change-Id: I2765b671664c2a84839b2f88ba724fdf0c1fa7c6
Diffstat (limited to 'src/corelib/tools/qbitarray.cpp')
| -rw-r--r-- | src/corelib/tools/qbitarray.cpp | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/src/corelib/tools/qbitarray.cpp b/src/corelib/tools/qbitarray.cpp index 446e09b1c05..12e4687b3c8 100644 --- a/src/corelib/tools/qbitarray.cpp +++ b/src/corelib/tools/qbitarray.cpp @@ -42,6 +42,7 @@ #include <qalgorithms.h> #include <qdatastream.h> #include <qdebug.h> +#include <qendian.h> #include <string.h> QT_BEGIN_NAMESPACE @@ -169,25 +170,6 @@ QBitArray::QBitArray(int size, bool value) Same as size(). */ -template <typename T> T qUnalignedLoad(const uchar *ptr) -{ - /* - * Testing with different compilers shows that they all optimize the memcpy - * call away and replace with direct loads whenever possible. On x86 and PPC, - * GCC does direct unaligned loads; on MIPS, it generates a pair of load-left - * and load-right instructions. ICC and Clang do the same on x86. This is both - * 32- and 64-bit. - * - * On ARM cores without unaligned loads, the compiler leaves a call to - * memcpy. - */ - - T u; - memcpy(&u, ptr, sizeof(u)); - return u; -} - - /*! If \a on is true, this function returns the number of 1-bits stored in the bit array; otherwise the number @@ -203,17 +185,17 @@ int QBitArray::count(bool on) const const quint8 *const end = reinterpret_cast<const quint8 *>(d.end()); while (bits + 7 <= end) { - quint64 v = qUnalignedLoad<quint64>(bits); + quint64 v = qFromUnaligned<quint64>(bits); bits += 8; numBits += int(qPopulationCount(v)); } if (bits + 3 <= end) { - quint32 v = qUnalignedLoad<quint32>(bits); + quint32 v = qFromUnaligned<quint32>(bits); bits += 4; numBits += int(qPopulationCount(v)); } if (bits + 1 < end) { - quint16 v = qUnalignedLoad<quint16>(bits); + quint16 v = qFromUnaligned<quint16>(bits); bits += 2; numBits += int(qPopulationCount(v)); } |
