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

@@ -40,7 +40,7 @@ public:
SymbolLocation();
//! Constructor
explicit SymbolLocation(QString file, int lineNumber = 0, int columnNumber = 0);
explicit SymbolLocation(const QString &file, int lineNumber = 0, int columnNumber = 0);
inline const QString &fileName() const { return m_fileName; }
inline int line() const { return m_line; }
@@ -48,15 +48,15 @@ public:
inline Utils::QHashValueType hash() const { return m_hash; }
inline bool operator==(const SymbolLocation &other) const
{
return line() == other.line() && column() == other.column()
return hash() == other.hash() && line() == other.line() && column() == other.column()
&& fileName() == other.fileName();
}
private:
QString m_fileName; //!< file name
int m_line; //!< line number
int m_column; //!< column
Utils::QHashValueType m_hash; //!< precalculated hash value for the object, to speed up qHash
const QString m_fileName;
const int m_line;
const int m_column;
const Utils::QHashValueType m_hash; // precalculated hash value - to speed up qHash
};
//! qHash overload for QHash/QSet