mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-13 16:30:29 -05: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 (DatabaseWidget* dbWidget = qobject_cast<DatabaseWidget*>(m_dbTabWidget->widget(i))) {
|
||||||
if (Database* db = dbWidget->database()) {
|
if (Database* db = dbWidget->database()) {
|
||||||
// Check if database is connected with KeePassXC-Browser
|
// 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);
|
QString key = db->metadata()->customData()->value(QLatin1String(ASSOCIATE_KEY_PREFIX) + keyPair.first);
|
||||||
if (!key.isEmpty() && keyPair.second == key) {
|
if (!key.isEmpty() && keyPair.second == key) {
|
||||||
databases << db;
|
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
|
// TODO: Replace with EntrySearcher
|
||||||
QStringList response;
|
QStringList response;
|
||||||
@ -934,15 +934,15 @@ QStringList Group::locate(QString locateTerm, QString currentPath)
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Entry* entry : asConst(m_entries)) {
|
for (const Entry* entry : asConst(m_entries)) {
|
||||||
QString entryPath = currentPath + entry->title();
|
QString entryPath = currentPath + entry->title();
|
||||||
if (entryPath.toLower().contains(locateTerm.toLower())) {
|
if (entryPath.toLower().contains(locateTerm.toLower())) {
|
||||||
response << entryPath;
|
response << entryPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Group* group : asConst(m_children)) {
|
for (const Group* group : asConst(m_children)) {
|
||||||
for (QString path : group->locate(locateTerm, currentPath + group->name() + QString("/"))) {
|
for (const QString& path : group->locate(locateTerm, currentPath + group->name() + QString("/"))) {
|
||||||
response << path;
|
response << path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ public:
|
|||||||
Entry* findEntryByPath(QString entryPath);
|
Entry* findEntryByPath(QString entryPath);
|
||||||
Group* findGroupByUuid(const QUuid& uuid);
|
Group* findGroupByUuid(const QUuid& uuid);
|
||||||
Group* findGroupByPath(QString groupPath);
|
Group* findGroupByPath(QString groupPath);
|
||||||
QStringList locate(QString locateTerm, QString currentPath = {"/"});
|
QStringList locate(QString locateTerm, QString currentPath = {"/"}) const;
|
||||||
Entry* addEntryWithPath(QString entryPath);
|
Entry* addEntryWithPath(QString entryPath);
|
||||||
void setUuid(const QUuid& uuid);
|
void setUuid(const QUuid& uuid);
|
||||||
void setName(const QString& name);
|
void setName(const QString& name);
|
||||||
|
@ -101,7 +101,7 @@ const QString OpenSSHKey::fingerprint(QCryptographicHash::Algorithm algo) const
|
|||||||
|
|
||||||
stream.writeString(m_type);
|
stream.writeString(m_type);
|
||||||
|
|
||||||
for (QByteArray ba : m_publicData) {
|
for (const QByteArray& ba : m_publicData) {
|
||||||
stream.writeString(ba);
|
stream.writeString(ba);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ const QString OpenSSHKey::publicKey() const
|
|||||||
|
|
||||||
stream.writeString(m_type);
|
stream.writeString(m_type);
|
||||||
|
|
||||||
for (QByteArray ba : m_publicData) {
|
for (const QByteArray& ba : m_publicData) {
|
||||||
stream.writeString(ba);
|
stream.writeString(ba);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -544,7 +544,7 @@ bool OpenSSHKey::writePublic(BinaryStream& stream)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (QByteArray t : m_publicData) {
|
for (const QByteArray& t : m_publicData) {
|
||||||
if (!stream.writeString(t)) {
|
if (!stream.writeString(t)) {
|
||||||
m_error = tr("Unexpected EOF when writing public key");
|
m_error = tr("Unexpected EOF when writing public key");
|
||||||
return false;
|
return false;
|
||||||
@ -566,7 +566,7 @@ bool OpenSSHKey::writePrivate(BinaryStream& stream)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (QByteArray t : m_privateData) {
|
for (const QByteArray& t : m_privateData) {
|
||||||
if (!stream.writeString(t)) {
|
if (!stream.writeString(t)) {
|
||||||
m_error = tr("Unexpected EOF when writing private key");
|
m_error = tr("Unexpected EOF when writing private key");
|
||||||
return false;
|
return false;
|
||||||
|
@ -38,7 +38,7 @@ SSHAgent::SSHAgent(QObject* parent)
|
|||||||
|
|
||||||
SSHAgent::~SSHAgent()
|
SSHAgent::~SSHAgent()
|
||||||
{
|
{
|
||||||
for (QSet<OpenSSHKey> keys : m_keys.values()) {
|
for (const QSet<OpenSSHKey>& keys : m_keys.values()) {
|
||||||
for (OpenSSHKey key : keys) {
|
for (OpenSSHKey key : keys) {
|
||||||
removeIdentity(key);
|
removeIdentity(key);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user