QSmallByteArray: add sufficient API to make conversion to QByteArrayView implicit
Iterators were missing. Provide a const data() overload to implement the iterator functions in their natural form. Pick-to: 6.5 Change-Id: I906013e55fce2effbedba0d283fb4cea3b512fdd Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
a62aa18178
commit
bdb13a1b31
@ -130,6 +130,7 @@ class QSmallByteArray
|
||||
public:
|
||||
// all SMFs are ok!
|
||||
quint8 *data() noexcept { return m_data.data(); }
|
||||
const quint8 *data() const noexcept { return m_data.data(); }
|
||||
qsizetype size() const noexcept { return qsizetype{m_size}; }
|
||||
quint8 &operator[](qsizetype n)
|
||||
{
|
||||
@ -144,8 +145,22 @@ public:
|
||||
Q_ASSERT(size_t(s) <= N);
|
||||
m_size = std::uint8_t(s);
|
||||
}
|
||||
void resize(qsizetype s, quint8 v)
|
||||
{
|
||||
const auto oldSize = size();
|
||||
resizeForOverwrite(s);
|
||||
if (s > oldSize)
|
||||
memset(data() + oldSize, v, size() - oldSize);
|
||||
}
|
||||
QByteArrayView toByteArrayView() const noexcept
|
||||
{ return QByteArrayView{m_data.data(), size()}; }
|
||||
{ return *this; }
|
||||
|
||||
auto begin() noexcept { return data(); }
|
||||
auto begin() const noexcept { return data(); }
|
||||
auto cbegin() const noexcept { return begin(); }
|
||||
auto end() noexcept { return data() + size(); }
|
||||
auto end() const noexcept { return data() + size(); }
|
||||
auto cend() const noexcept { return end(); }
|
||||
};
|
||||
|
||||
static constexpr int hashLengthInternal(QCryptographicHash::Algorithm method) noexcept
|
||||
@ -1260,8 +1275,8 @@ void QMessageAuthenticationCodePrivate::finalizeUnchecked() noexcept
|
||||
oKeyPad[i] = keyData[i] ^ 0x5c;
|
||||
|
||||
messageHash.reset();
|
||||
messageHash.addData(oKeyPad.toByteArrayView());
|
||||
messageHash.addData(hashedMessage.toByteArrayView());
|
||||
messageHash.addData(oKeyPad);
|
||||
messageHash.addData(hashedMessage);
|
||||
messageHash.finalizeUnchecked();
|
||||
|
||||
result = messageHash.result;
|
||||
|
Loading…
x
Reference in New Issue
Block a user