de-inline QBuffer::setData() overload for performance reasons

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-01-12 16:31:54 +02:00
parent 82907043ec
commit 2f18658551
2 changed files with 12 additions and 6 deletions

View file

@ -294,7 +294,7 @@ const QByteArray &QBuffer::data() const
*/ */
void QBuffer::setData(const QByteArray &data) void QBuffer::setData(const QByteArray &data)
{ {
if (isOpen()) { if (Q_UNLIKELY(isOpen())) {
qWarning("QBuffer::setData: Buffer is open"); qWarning("QBuffer::setData: Buffer is open");
return; return;
} }
@ -303,13 +303,20 @@ void QBuffer::setData(const QByteArray &data)
} }
/*! /*!
\fn void QBuffer::setData(const char *data, int size)
\overload \overload
Sets the contents of the internal buffer to be the first \a size Sets the contents of the internal buffer to be the first \a size
bytes of \a data. bytes of \a data, does not copy the data.
*/ */
void QBuffer::setData(const char *data, const int len)
{
if (Q_UNLIKELY(isOpen())) {
qWarning("QBuffer::setData: Buffer is open");
return;
}
Q_D(QBuffer);
d->buf->setRawData(data, len);
}
/*! /*!
\reimp \reimp

View file

@ -63,8 +63,7 @@ public:
void setBuffer(QByteArray *a); void setBuffer(QByteArray *a);
void setData(const QByteArray &data); void setData(const QByteArray &data);
inline void setData(const char *data, const int len) void setData(const char *data, const int len);
{ setData(QByteArray::fromRawData(data, len)); }
const QByteArray &data() const; const QByteArray &data() const;
bool open(OpenMode openMode); bool open(OpenMode openMode);