Replace QMap with QHash when the key is a pointer

QHash gives faster lookups than QMap when the key is a pointer.
This commit is contained in:
Gianluca Recchia 2019-01-17 06:03:58 +01:00 committed by Jonathan White
parent 9a5bbea2e4
commit ffea029001
No known key found for this signature in database
GPG Key ID: 440FC65F2E0C6E01
2 changed files with 4 additions and 3 deletions

View File

@ -20,8 +20,8 @@
MessageBox::Button MessageBox::m_nextAnswer(MessageBox::NoButton);
QMap<QAbstractButton*, MessageBox::Button> MessageBox::m_addedButtonLookup =
QMap<QAbstractButton*, MessageBox::Button>();
QHash<QAbstractButton*, MessageBox::Button> MessageBox::m_addedButtonLookup =
QHash<QAbstractButton*, MessageBox::Button>();
QMap<MessageBox::Button, std::pair<QString, QMessageBox::ButtonRole>> MessageBox::m_buttonDefs =
QMap<MessageBox::Button, std::pair<QString, QMessageBox::ButtonRole>>();

View File

@ -19,6 +19,7 @@
#ifndef KEEPASSX_MESSAGEBOX_H
#define KEEPASSX_MESSAGEBOX_H
#include <QHash>
#include <QMap>
#include <QMessageBox>
#include <QPushButton>
@ -102,7 +103,7 @@ public:
private:
static Button m_nextAnswer;
static QMap<QAbstractButton*, Button> m_addedButtonLookup;
static QHash<QAbstractButton*, Button> m_addedButtonLookup;
static QMap<Button, std::pair<QString, QMessageBox::ButtonRole>> m_buttonDefs;
static Button messageBox(QWidget* parent,