forked from qt-creator/qt-creator
Use QHash instead of QMap when key is a pointer type
Ordering in container by pointer to memory doesn't make much sense. QHash is faster for lookups in this case. Change-Id: I0d4bdac7f5bb9afffdeaef70b99326547c080f55 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -105,7 +105,7 @@ ProjectTestSettingsWidget::ProjectTestSettingsWidget(ProjectExplorer::Project *p
|
||||
TestTreeModel::instance(), &TestTreeModel::synchronizeTestFrameworks);
|
||||
}
|
||||
|
||||
void ProjectTestSettingsWidget::populateFrameworks(const QMap<ITestFramework *, bool> &frameworks)
|
||||
void ProjectTestSettingsWidget::populateFrameworks(const QHash<ITestFramework *, bool> &frameworks)
|
||||
{
|
||||
TestFrameworks sortedFrameworks = frameworks.keys();
|
||||
Utils::sort(sortedFrameworks, &ITestFramework::priority);
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
explicit ProjectTestSettingsWidget(ProjectExplorer::Project *project,
|
||||
QWidget *parent = nullptr);
|
||||
private:
|
||||
void populateFrameworks(const QMap<Autotest::ITestFramework *, bool> &frameworks);
|
||||
void populateFrameworks(const QHash<Autotest::ITestFramework *, bool> &frameworks);
|
||||
void onActiveFrameworkChanged(QTreeWidgetItem *item, int column);
|
||||
TestProjectSettings *m_projectSettings;
|
||||
QComboBox *m_useGlobalSettings = nullptr;
|
||||
|
||||
@@ -47,9 +47,9 @@ public:
|
||||
bool useGlobalSettings() const { return m_useGlobalSettings; }
|
||||
void setRunAfterBuild(RunAfterBuildMode mode) {m_runAfterBuild = mode; }
|
||||
RunAfterBuildMode runAfterBuild() const { return m_runAfterBuild; }
|
||||
void setActiveFrameworks(const QMap<ITestFramework *, bool> enabledFrameworks)
|
||||
void setActiveFrameworks(const QHash<ITestFramework *, bool> enabledFrameworks)
|
||||
{ m_activeTestFrameworks = enabledFrameworks; }
|
||||
QMap<ITestFramework *, bool> activeFrameworks() const { return m_activeTestFrameworks; }
|
||||
QHash<ITestFramework *, bool> activeFrameworks() const { return m_activeTestFrameworks; }
|
||||
void activateFramework(const Utils::Id &id, bool activate);
|
||||
Internal::ItemDataCache<Qt::CheckState> *checkStateCache() { return &m_checkStateCache; }
|
||||
private:
|
||||
@@ -59,7 +59,7 @@ private:
|
||||
ProjectExplorer::Project *m_project;
|
||||
bool m_useGlobalSettings = true;
|
||||
RunAfterBuildMode m_runAfterBuild = RunAfterBuildMode::None;
|
||||
QMap<ITestFramework *, bool> m_activeTestFrameworks;
|
||||
QHash<ITestFramework *, bool> m_activeTestFrameworks;
|
||||
Internal::ItemDataCache<Qt::CheckState> m_checkStateCache;
|
||||
};
|
||||
|
||||
|
||||
@@ -235,7 +235,7 @@ void TestTreeModel::synchronizeTestFrameworks()
|
||||
qCDebug(LOG) << "Active frameworks sorted by priority" << sorted;
|
||||
} else { // we've got custom project settings
|
||||
const TestProjectSettings *settings = AutotestPlugin::projectSettings(project);
|
||||
const QMap<ITestFramework *, bool> active = settings->activeFrameworks();
|
||||
const QHash<ITestFramework *, bool> active = settings->activeFrameworks();
|
||||
sorted = Utils::filtered(active.keys(), [active](ITestFramework *framework) {
|
||||
return active.value(framework);
|
||||
});
|
||||
|
||||
@@ -53,7 +53,7 @@ void VirtualFileSystemOverlay::update()
|
||||
return;
|
||||
std::map<Utils::FilePath, QList<Core::IDocument *>> documentRoots;
|
||||
const QList<Core::IDocument *> &modifiedDocuments = Core::DocumentManager::modifiedDocuments();
|
||||
QMap<Core::IDocument *, AutoSavedPath> newSaved;
|
||||
QHash<Core::IDocument *, AutoSavedPath> newSaved;
|
||||
for (Core::IDocument *doc : modifiedDocuments) {
|
||||
auto document = qobject_cast<TextEditor::TextDocument *>(doc);
|
||||
if (!document)
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
|
||||
#include <QHash>
|
||||
#include <QMap>
|
||||
|
||||
namespace Core { class IDocument; }
|
||||
@@ -55,7 +56,7 @@ private:
|
||||
Utils::FilePath path;
|
||||
};
|
||||
|
||||
QMap<Core::IDocument *, AutoSavedPath> m_saved;
|
||||
QHash<Core::IDocument *, AutoSavedPath> m_saved;
|
||||
QMap<Utils::FilePath, Utils::FilePath> m_mapping;
|
||||
};
|
||||
|
||||
|
||||
@@ -351,7 +351,7 @@ FilePaths VcsManager::promptToDelete(const FilePaths &filePaths)
|
||||
}
|
||||
|
||||
// Categorize by version control system.
|
||||
QMap<IVersionControl *, FilePaths> filesByVersionControl;
|
||||
QHash<IVersionControl *, FilePaths> filesByVersionControl;
|
||||
for (auto it = filesByParentDir.cbegin(); it != filesByParentDir.cend(); ++it) {
|
||||
IVersionControl * const vc = findVersionControlForDirectory(it.key().toString());
|
||||
if (vc)
|
||||
|
||||
@@ -207,7 +207,7 @@ void updateEditorToolBar(Core::IEditor *editor)
|
||||
TextDocument *document = textEditor->textDocument();
|
||||
Client *client = LanguageClientManager::clientForDocument(textEditor->textDocument());
|
||||
|
||||
static QMap<QWidget *, QAction *> actions;
|
||||
static QHash<QWidget *, QAction *> actions;
|
||||
|
||||
if (actions.contains(widget)) {
|
||||
auto action = actions[widget];
|
||||
@@ -253,7 +253,7 @@ void updateEditorToolBar(Core::IEditor *editor)
|
||||
});
|
||||
}
|
||||
|
||||
static QMap<QWidget *, QPair<Client *, QAction *>> outlines;
|
||||
static QHash<QWidget *, QPair<Client *, QAction *>> outlines;
|
||||
|
||||
if (outlines.contains(widget)) {
|
||||
auto outline = outlines[widget];
|
||||
|
||||
Reference in New Issue
Block a user