Improve performance of a few for-loops

Some for-loops needlessly copied the collection they were looping over.
This commit is contained in:
Gianluca Recchia 2018-10-27 23:23:34 +02:00
parent e2ee82169c
commit 4876beabed
No known key found for this signature in database
GPG key ID: 3C2B4128D9A1F218
5 changed files with 11 additions and 11 deletions

View file

@ -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;

View file

@ -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);
}