StringTable: Remove redundant isMutable() check

It's included in isShared() already, which looks like:
bool isShared() const noexcept { return !d || d->isShared(); }

The isMutable() looks like:
bool isMutable() const noexcept { return d; }

So, if d == nullptr, isShared() == true, thus !isMutable() == true.
In this case !isMutable is no-op.
Otherwise, if d != nullptr, !isMutable() == false, thus or'ing it
with isShared() is also no-op.

The public access to isShared() is via the negation of
QString::isDetached().

Change-Id: If9a2c3d635504e9f54ae608b192bd9b2fb7a12f5
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Jarek Kobus
2025-02-03 18:27:55 +01:00
parent ec65481b54
commit 68627afdbe

View File

@@ -103,14 +103,14 @@ static int bytesSaved = 0;
static inline bool isQStringInUse(const QString &string)
{
QStringPrivate &data_ptr = const_cast<QString&>(string).data_ptr();
if (DebugStringTable) {
QStringPrivate &data_ptr = const_cast<QString&>(string).data_ptr();
const int ref = data_ptr->d_ptr()->ref_;
bytesSaved += (ref - 1) * string.size();
if (ref > 10)
qDebug() << ref << string.size() << string.left(50);
}
return data_ptr->isShared() || !data_ptr->isMutable() /* QStringLiteral ? */;
return !string.isDetached();
}
void StringTablePrivate::GC(QPromise<void> &promise)