QString: make isEmpty(), length() and size() noexcept

They have no preconditions and cannot throw.

As a drive-by, merge the definition of isEmpty() into its declaration.

Pick-to: 6.6
Change-Id: Ifffa0d4cb2a285bb802d39d10a757be9c31cfae1
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
bb10
Dennis Oberst 2023-07-14 10:06:36 +02:00 committed by Marc Mutz
parent 0cae76c2af
commit 464461dea6
1 changed files with 3 additions and 5 deletions

View File

@ -179,13 +179,13 @@ public:
= default;
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QString)
void swap(QString &other) noexcept { d.swap(other.d); }
inline qsizetype size() const { return d.size; }
inline qsizetype size() const noexcept { return d.size; }
#if QT_DEPRECATED_SINCE(6, 4)
QT_DEPRECATED_VERSION_X_6_4("Use size() or length() instead.")
inline qsizetype count() const { return d.size; }
#endif
inline qsizetype length() const { return d.size; }
inline bool isEmpty() const;
inline qsizetype length() const noexcept { return d.size; }
inline bool isEmpty() const noexcept { return d.size == 0; }
void resize(qsizetype size);
void resize(qsizetype size, QChar fillChar);
@ -1082,8 +1082,6 @@ inline const QChar QString::at(qsizetype i) const
{ Q_ASSERT(size_t(i) < size_t(size())); return QChar(d.data()[i]); }
inline const QChar QString::operator[](qsizetype i) const
{ Q_ASSERT(size_t(i) < size_t(size())); return QChar(d.data()[i]); }
inline bool QString::isEmpty() const
{ return d.size == 0; }
inline const QChar *QString::unicode() const
{ return data(); }
inline const QChar *QString::data() const