mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Improve performance of a few for-loops
Some for-loops needlessly copied the collection they were looping over.
This commit is contained in:
parent
e2ee82169c
commit
4876beabed
@ -421,7 +421,7 @@ QList<Entry*> BrowserService::searchEntries(const QString& url, const StringPair
|
||||
if (DatabaseWidget* dbWidget = qobject_cast<DatabaseWidget*>(m_dbTabWidget->widget(i))) {
|
||||
if (Database* db = dbWidget->database()) {
|
||||
// Check if database is connected with KeePassXC-Browser
|
||||
for (const StringPair keyPair : keyList) {
|
||||
for (const StringPair& keyPair : keyList) {
|
||||
QString key = db->metadata()->customData()->value(QLatin1String(ASSOCIATE_KEY_PREFIX) + keyPair.first);
|
||||
if (!key.isEmpty() && keyPair.second == key) {
|
||||
databases << db;
|
||||
|
@ -926,7 +926,7 @@ bool Group::resolveAutoTypeEnabled() const
|
||||
}
|
||||
}
|
||||
|
||||
QStringList Group::locate(QString locateTerm, QString currentPath)
|
||||
QStringList Group::locate(QString locateTerm, QString currentPath) const
|
||||
{
|
||||
// TODO: Replace with EntrySearcher
|
||||
QStringList response;
|
||||
@ -934,15 +934,15 @@ QStringList Group::locate(QString locateTerm, QString currentPath)
|
||||
return response;
|
||||
}
|
||||
|
||||
for (Entry* entry : asConst(m_entries)) {
|
||||
for (const Entry* entry : asConst(m_entries)) {
|
||||
QString entryPath = currentPath + entry->title();
|
||||
if (entryPath.toLower().contains(locateTerm.toLower())) {
|
||||
response << entryPath;
|
||||
}
|
||||
}
|
||||
|
||||
for (Group* group : asConst(m_children)) {
|
||||
for (QString path : group->locate(locateTerm, currentPath + group->name() + QString("/"))) {
|
||||
for (const Group* group : asConst(m_children)) {
|
||||
for (const QString& path : group->locate(locateTerm, currentPath + group->name() + QString("/"))) {
|
||||
response << path;
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ public:
|
||||
Entry* findEntryByPath(QString entryPath);
|
||||
Group* findGroupByUuid(const QUuid& uuid);
|
||||
Group* findGroupByPath(QString groupPath);
|
||||
QStringList locate(QString locateTerm, QString currentPath = {"/"});
|
||||
QStringList locate(QString locateTerm, QString currentPath = {"/"}) const;
|
||||
Entry* addEntryWithPath(QString entryPath);
|
||||
void setUuid(const QUuid& uuid);
|
||||
void setName(const QString& name);
|
||||
|
@ -101,7 +101,7 @@ const QString OpenSSHKey::fingerprint(QCryptographicHash::Algorithm algo) const
|
||||
|
||||
stream.writeString(m_type);
|
||||
|
||||
for (QByteArray ba : m_publicData) {
|
||||
for (const QByteArray& ba : m_publicData) {
|
||||
stream.writeString(ba);
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ const QString OpenSSHKey::publicKey() const
|
||||
|
||||
stream.writeString(m_type);
|
||||
|
||||
for (QByteArray ba : m_publicData) {
|
||||
for (const QByteArray& ba : m_publicData) {
|
||||
stream.writeString(ba);
|
||||
}
|
||||
|
||||
@ -544,7 +544,7 @@ bool OpenSSHKey::writePublic(BinaryStream& stream)
|
||||
return false;
|
||||
}
|
||||
|
||||
for (QByteArray t : m_publicData) {
|
||||
for (const QByteArray& t : m_publicData) {
|
||||
if (!stream.writeString(t)) {
|
||||
m_error = tr("Unexpected EOF when writing public key");
|
||||
return false;
|
||||
@ -566,7 +566,7 @@ bool OpenSSHKey::writePrivate(BinaryStream& stream)
|
||||
return false;
|
||||
}
|
||||
|
||||
for (QByteArray t : m_privateData) {
|
||||
for (const QByteArray& t : m_privateData) {
|
||||
if (!stream.writeString(t)) {
|
||||
m_error = tr("Unexpected EOF when writing private key");
|
||||
return false;
|
||||
|
@ -38,7 +38,7 @@ SSHAgent::SSHAgent(QObject* parent)
|
||||
|
||||
SSHAgent::~SSHAgent()
|
||||
{
|
||||
for (QSet<OpenSSHKey> keys : m_keys.values()) {
|
||||
for (const QSet<OpenSSHKey>& keys : m_keys.values()) {
|
||||
for (OpenSSHKey key : keys) {
|
||||
removeIdentity(key);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user