QBitArray: simplify (size, value) ctor
Don't do the memset() manually just to save re-writing the single leading byte. Pass the initial values to the QByteArray constructor directly. Change-Id: I67daf446bebb8c8c6b05d235746ee43604f42445 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 0d6ca27517523e960b132bd5e51d9b48bb9a93a3) Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
parent
d55d8d9620
commit
0a2104f50c
@ -133,14 +133,12 @@ static void adjust_head_and_tail(char *data, qsizetype storageSize, qsizetype lo
|
||||
initialized with \a value, which defaults to false (0).
|
||||
*/
|
||||
QBitArray::QBitArray(qsizetype size, bool value)
|
||||
: d(allocation_size(size), Qt::Uninitialized)
|
||||
: d(allocation_size(size), value ? 0xFF : 0x00)
|
||||
{
|
||||
Q_ASSERT_X(size >= 0, "QBitArray::QBitArray", "Size must be greater than or equal to 0.");
|
||||
if (size <= 0)
|
||||
return;
|
||||
|
||||
uchar *c = reinterpret_cast<uchar *>(d.data());
|
||||
memset(c + 1, value ? 0xff : 0, d.size() - 1);
|
||||
adjust_head_and_tail(d.data(), d.size(), size);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user