QByteArray: de-inline to/fromStdString()
Removes another owning container manipulation that made the top entry in Clang -ftime-trace's most-expensive template instantiations in a QtWidgets build. Task-number: QTBUG-97601 Change-Id: I8c765ea2e6c46da5188b70c9503dd87e63f6b328 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit d6575f37179aef80490f4ec03a61ab6f5033bd3d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
dd78bdb992
commit
b19dc4a527
@ -4561,6 +4561,10 @@ QByteArray QByteArray::fromPercentEncoding(const QByteArray &input, char percent
|
||||
|
||||
\sa toStdString(), QString::fromStdString()
|
||||
*/
|
||||
QByteArray QByteArray::fromStdString(const std::string &s)
|
||||
{
|
||||
return QByteArray(s.data(), qsizetype(s.size()));
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn std::string QByteArray::toStdString() const
|
||||
@ -4574,6 +4578,10 @@ QByteArray QByteArray::fromPercentEncoding(const QByteArray &input, char percent
|
||||
|
||||
\sa fromStdString(), QString::toStdString()
|
||||
*/
|
||||
std::string QByteArray::toStdString() const
|
||||
{
|
||||
return std::string(data(), size_t(size()));
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.4
|
||||
|
@ -430,8 +430,8 @@ public:
|
||||
void shrink_to_fit() { squeeze(); }
|
||||
iterator erase(const_iterator first, const_iterator last);
|
||||
|
||||
static inline QByteArray fromStdString(const std::string &s);
|
||||
inline std::string toStdString() const;
|
||||
static QByteArray fromStdString(const std::string &s);
|
||||
std::string toStdString() const;
|
||||
|
||||
inline qsizetype size() const noexcept { return d->size; }
|
||||
#if QT_DEPRECATED_SINCE(6, 4)
|
||||
@ -567,12 +567,6 @@ inline QByteArray &QByteArray::setNum(ulong n, int base)
|
||||
inline QByteArray &QByteArray::setNum(float n, char format, int precision)
|
||||
{ return setNum(double(n), format, precision); }
|
||||
|
||||
inline std::string QByteArray::toStdString() const
|
||||
{ return std::string(constData(), length()); }
|
||||
|
||||
inline QByteArray QByteArray::fromStdString(const std::string &s)
|
||||
{ return QByteArray(s.data(), qsizetype(s.size())); }
|
||||
|
||||
#if !defined(QT_NO_DATASTREAM) || defined(QT_BOOTSTRAPPED)
|
||||
Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QByteArray &);
|
||||
Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QByteArray &);
|
||||
|
Loading…
x
Reference in New Issue
Block a user