diff options
author | Yuhang Zhao <2546789017@qq.com> | 2019-12-30 18:28:33 +0800 |
---|---|---|
committer | Yuhang Zhao <2546789017@qq.com> | 2020-01-04 18:19:13 +0800 |
commit | e65c43fd0ffa57248e7d750570b7deae171a82f5 (patch) | |
tree | f4658203e393c359ab1198d75ea76e5e0acc982c /src/corelib | |
parent | d593c5865acb544d02e45ac24245d9bc9988ffb1 (diff) |
Code style fix
Amends commit a0eb51c3870d90c06966dbfbe26b114f39103b60
Change-Id: Ida0bf55cb9a056607181241dd84522a010c40890
Reviewed-by: Federico Guerinoni <guerinoni@micro-systems.it>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/tools/qbitarray.cpp | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/corelib/tools/qbitarray.cpp b/src/corelib/tools/qbitarray.cpp index 4db0f61599..a1dd537d4d 100644 --- a/src/corelib/tools/qbitarray.cpp +++ b/src/corelib/tools/qbitarray.cpp @@ -343,34 +343,32 @@ QBitArray QBitArray::fromBits(const char *data, qsizetype size) } /*! - \since 5.13 + \since 6.0 - Returns the array of bit converted to an int. The conversion is based of endianness value. - Converts up to the first 32 bits of the array to \c uint32_t and returns it, - obeying \a endianness. If the array has more than 32 bits, \a ok is set to false - and this function returns zero; otherwise, it's set to true. + Returns the array of bit converted to an int. The conversion is based on \a endianness. + Converts up to the first 32 bits of the array to \c quint32 and returns it, + obeying \a endianness. If \a ok is not a null pointer, and the array has more + than 32 bits, \a ok is set to false and this function returns zero; otherwise, + it's set to true. */ quint32 QBitArray::toUInt32(QSysInfo::Endian endianness, bool *ok) const noexcept { - if (size() > 32) { - if (ok != nullptr) { + const qsizetype _size = size(); + if (_size > 32) { + if (ok) *ok = false; - } - return 0; } - if (ok != nullptr) { + if (ok) *ok = true; - } - auto factor = 1; + quint32 factor = 1; quint32 total = 0; - for (auto i = 0; i < size(); ++i, factor *= 2) { - const auto index = endianness == QSysInfo::Endian::LittleEndian ? i : (size() - i - 1); - if (testBit(index)) { + for (qsizetype i = 0; i < _size; ++i, factor *= 2) { + const auto index = endianness == QSysInfo::Endian::LittleEndian ? i : (_size - i - 1); + if (testBit(index)) total += factor; - } } return total; |