aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/classview/classviewmanager.cpp
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2021-02-16 01:37:49 +0100
committerJarek Kobus <jaroslaw.kobus@qt.io>2021-02-16 09:41:56 +0000
commit4a15f6d16bbcd4ec6a75dd03ef38657264982b82 (patch)
treeb01d85ca7592f6fcf0759fefa9b739f5a4014c2f /src/plugins/classview/classviewmanager.cpp
parent06f305265b5f8a1e90d5369312298fe14a3f34ba (diff)
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>
Diffstat (limited to 'src/plugins/classview/classviewmanager.cpp')
-rw-r--r--src/plugins/classview/classviewmanager.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/plugins/classview/classviewmanager.cpp b/src/plugins/classview/classviewmanager.cpp
index ce5bfcec20..8284071d21 100644
--- a/src/plugins/classview/classviewmanager.cpp
+++ b/src/plugins/classview/classviewmanager.cpp
@@ -317,8 +317,7 @@ void Manager::gotoLocations(const QList<QVariant> &list)
return;
// Default to first known location
- SymbolLocation loc = *locations.constBegin();
-
+ auto locationIt = locations.constBegin();
if (locations.size() > 1) {
// The symbol has multiple locations. Check if we are already at one location,
// and if so, cycle to the "next" one
@@ -329,20 +328,19 @@ void Manager::gotoLocations(const QList<QVariant> &list)
int line;
int column;
textEditor->convertPosition(textEditor->position(), &line, &column);
- SymbolLocation current(fileName, line, column);
- QSet<SymbolLocation>::const_iterator it = locations.constFind(current);
- QSet<SymbolLocation>::const_iterator end = locations.constEnd();
- if (it != end) {
+ const SymbolLocation current(fileName, line, column);
+ if (auto it = locations.constFind(current), end = locations.constEnd(); it != end) {
// we already are at the symbol, cycle to next location
++it;
if (it == end)
it = locations.constBegin();
- loc = *it;
+ locationIt = it;
}
}
}
+ const SymbolLocation &location = *locationIt;
// line is 1-based, column is 0-based
- gotoLocation(loc.fileName(), loc.line(), loc.column() - 1);
+ gotoLocation(location.fileName(), location.line(), location.column() - 1);
}
/*!