ClassView: Optimize operator== of internal data

Make all of the fields of SymbolLocation and SymbolInformation
const members. Optimize a bit operator== of these structures:
check first if hashes are non-equal - in this case return
false early. Fix hash type of SymbolInformation for porting
to Qt6 purpose.

Task-number: QTCREATORBUG-25317
Task-number: QTCREATORBUG-24098
Change-Id: I769f99ff3157093e9f10ee3929bc7f6eb83f34e3
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Jarek Kobus
2021-02-16 01:37:49 +01:00
parent 06f305265b
commit 4a15f6d16b
6 changed files with 38 additions and 37 deletions

View File

@@ -49,13 +49,16 @@ SymbolInformation::SymbolInformation() :
}
SymbolInformation::SymbolInformation(const QString &valueName, const QString &valueType,
int valueIconType) :
m_iconType(valueIconType),
m_name(valueName),
m_type(valueType)
int valueIconType)
: m_iconType(valueIconType)
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
, m_hash(qHashMulti(0, valueIconType, valueName, valueType))
#else
, m_hash(qHash(qMakePair(valueIconType, qMakePair(valueName, valueType))))
#endif
, m_name(valueName)
, m_type(valueType)
{
// calculate hash
m_hash = qHash(qMakePair(m_iconType, qMakePair(m_name, m_type)));
}
/*!
@@ -94,7 +97,8 @@ int SymbolInformation::iconTypeSortOrder() const
static QHash<int, int> sortOrder;
// initialization
// TODO: Check if this static initialization is OK when SymbolInformation object are
// instantiated in different threads.
if (sortOrder.isEmpty()) {
for (int i : IconSortOrder)
sortOrder.insert(i, sortOrder.count());