From 68627afdbe1f360a10db7788c272312fc552949a Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Mon, 3 Feb 2025 18:27:55 +0100 Subject: [PATCH] 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 Reviewed-by: Fabian Kosmale --- src/libs/utils/stringtable.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/utils/stringtable.cpp b/src/libs/utils/stringtable.cpp index 0dde8ed59f9..49caca48581 100644 --- a/src/libs/utils/stringtable.cpp +++ b/src/libs/utils/stringtable.cpp @@ -103,14 +103,14 @@ static int bytesSaved = 0; static inline bool isQStringInUse(const QString &string) { - QStringPrivate &data_ptr = const_cast(string).data_ptr(); if (DebugStringTable) { + QStringPrivate &data_ptr = const_cast(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 &promise)