Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGianluca Recchia <gianluca.recchia97@gmail.com>2018-10-28 14:49:32 +0300
committerGianluca Recchia <gianluca.recchia97@gmail.com>2018-10-31 17:16:04 +0300
commitda9afd3f6fcb7b7c3c5c02112ffe49c1ee34ba43 (patch)
treef25517212eeb197b0d452b0b3ec40bd9279d653d /src
parenta67a574b89ae1e12de158d6fdc5b51fdec6f13f3 (diff)
Reduce number of unneeded copies
This patch aims at reducing the number of copies for obejcts that could be referenced rather than copied, because they're not modified during the computation.
Diffstat (limited to 'src')
-rw-r--r--src/browser/BrowserAction.cpp8
-rw-r--r--src/browser/BrowserAction.h8
-rw-r--r--src/browser/BrowserSettings.cpp8
-rw-r--r--src/browser/BrowserSettings.h8
-rw-r--r--src/cli/Clip.cpp2
-rw-r--r--src/cli/Clip.h2
-rw-r--r--src/cli/Command.cpp2
-rw-r--r--src/cli/Command.h2
-rw-r--r--src/core/CsvParser.cpp6
-rw-r--r--src/core/CsvParser.h4
-rw-r--r--src/core/Database.cpp12
-rw-r--r--src/core/Database.h12
-rw-r--r--src/core/EntrySearcher.cpp4
-rw-r--r--src/core/Group.cpp12
-rw-r--r--src/core/Group.h12
-rw-r--r--src/core/PasswordGenerator.cpp2
-rw-r--r--src/core/PasswordGenerator.h2
-rw-r--r--src/format/CsvExporter.cpp4
-rw-r--r--src/format/KeePass2.cpp4
-rw-r--r--src/format/KeePass2.h4
-rw-r--r--src/gui/EditWidgetIcons.cpp4
-rw-r--r--src/gui/FileDialog.cpp2
-rw-r--r--src/gui/FileDialog.h2
-rw-r--r--src/gui/MainWindow.cpp2
-rw-r--r--src/gui/MainWindow.h2
-rw-r--r--src/gui/PasswordEdit.cpp2
-rw-r--r--src/gui/PasswordEdit.h2
-rw-r--r--src/gui/csvImport/CsvImportWidget.cpp4
-rw-r--r--src/gui/csvImport/CsvImportWidget.h4
-rw-r--r--src/gui/entry/AutoTypeMatchModel.cpp2
-rw-r--r--src/gui/entry/AutoTypeMatchModel.h2
-rw-r--r--src/gui/entry/AutoTypeMatchView.cpp2
-rw-r--r--src/gui/entry/AutoTypeMatchView.h2
-rw-r--r--src/gui/entry/EntryHistoryModel.cpp2
-rw-r--r--src/keys/CompositeKey.cpp4
-rw-r--r--src/keys/CompositeKey.h4
-rw-r--r--src/streams/HmacBlockStream.cpp2
-rw-r--r--src/streams/HmacBlockStream.h2
-rw-r--r--src/totp/totp.cpp8
-rw-r--r--src/totp/totp.h8
40 files changed, 90 insertions, 90 deletions
diff --git a/src/browser/BrowserAction.cpp b/src/browser/BrowserAction.cpp
index fcbc318ee..ccd17c5fd 100644
--- a/src/browser/BrowserAction.cpp
+++ b/src/browser/BrowserAction.cpp
@@ -468,7 +468,7 @@ QJsonObject BrowserAction::decryptMessage(const QString& message, const QString&
return getErrorReply(action, ERROR_KEEPASS_CANNOT_DECRYPT_MESSAGE);
}
-QString BrowserAction::encrypt(const QString plaintext, const QString nonce)
+QString BrowserAction::encrypt(const QString& plaintext, const QString& nonce)
{
QMutexLocker locker(&m_mutex);
const QByteArray ma = plaintext.toUtf8();
@@ -496,7 +496,7 @@ QString BrowserAction::encrypt(const QString plaintext, const QString nonce)
return QString();
}
-QByteArray BrowserAction::decrypt(const QString encrypted, const QString nonce)
+QByteArray BrowserAction::decrypt(const QString& encrypted, const QString& nonce)
{
QMutexLocker locker(&m_mutex);
const QByteArray ma = base64Decode(encrypted);
@@ -546,14 +546,14 @@ QJsonObject BrowserAction::getJsonObject(const uchar* pArray, const uint len) co
return doc.object();
}
-QJsonObject BrowserAction::getJsonObject(const QByteArray ba) const
+QJsonObject BrowserAction::getJsonObject(const QByteArray& ba) const
{
QJsonParseError err;
QJsonDocument doc(QJsonDocument::fromJson(ba, &err));
return doc.object();
}
-QByteArray BrowserAction::base64Decode(const QString str)
+QByteArray BrowserAction::base64Decode(const QString& str)
{
return QByteArray::fromBase64(str.toUtf8());
}
diff --git a/src/browser/BrowserAction.h b/src/browser/BrowserAction.h
index 5a7c83bf8..b7a60938f 100644
--- a/src/browser/BrowserAction.h
+++ b/src/browser/BrowserAction.h
@@ -73,14 +73,14 @@ private:
QString encryptMessage(const QJsonObject& message, const QString& nonce);
QJsonObject decryptMessage(const QString& message, const QString& nonce, const QString& action = QString());
- QString encrypt(const QString plaintext, const QString nonce);
- QByteArray decrypt(const QString encrypted, const QString nonce);
+ QString encrypt(const QString& plaintext, const QString& nonce);
+ QByteArray decrypt(const QString& encrypted, const QString& nonce);
QString getBase64FromKey(const uchar* array, const uint len);
QByteArray getQByteArray(const uchar* array, const uint len) const;
QJsonObject getJsonObject(const uchar* pArray, const uint len) const;
- QJsonObject getJsonObject(const QByteArray ba) const;
- QByteArray base64Decode(const QString str);
+ QJsonObject getJsonObject(const QByteArray& ba) const;
+ QByteArray base64Decode(const QString& str);
QString incrementNonce(const QString& nonce);
private:
diff --git a/src/browser/BrowserSettings.cpp b/src/browser/BrowserSettings.cpp
index 630d0ff18..646c6c4d3 100644
--- a/src/browser/BrowserSettings.cpp
+++ b/src/browser/BrowserSettings.cpp
@@ -169,7 +169,7 @@ QString BrowserSettings::customProxyLocation()
return config()->get("Browser/CustomProxyLocation", "").toString();
}
-void BrowserSettings::setCustomProxyLocation(QString location)
+void BrowserSettings::setCustomProxyLocation(const QString& location)
{
config()->set("Browser/CustomProxyLocation", location);
}
@@ -364,7 +364,7 @@ QString BrowserSettings::passwordExcludedChars()
return config()->get("generator/ExcludedChars", PasswordGenerator::DefaultExcludedChars).toString();
}
-void BrowserSettings::setPasswordExcludedChars(QString chars)
+void BrowserSettings::setPasswordExcludedChars(const QString& chars)
{
config()->set("generator/ExcludedChars", chars);
}
@@ -384,7 +384,7 @@ QString BrowserSettings::passPhraseWordSeparator()
return config()->get("generator/WordSeparator", PassphraseGenerator::DefaultSeparator).toString();
}
-void BrowserSettings::setPassPhraseWordSeparator(QString separator)
+void BrowserSettings::setPassPhraseWordSeparator(const QString& separator)
{
config()->set("generator/WordSeparator", separator);
}
@@ -496,7 +496,7 @@ QString BrowserSettings::generatePassword()
}
}
-void BrowserSettings::updateBinaryPaths(QString customProxyLocation)
+void BrowserSettings::updateBinaryPaths(const QString& customProxyLocation)
{
bool isProxy = supportBrowserProxy();
m_hostInstaller.updateBinaryPaths(isProxy, customProxyLocation);
diff --git a/src/browser/BrowserSettings.h b/src/browser/BrowserSettings.h
index 2e7c55ec6..92cdcd16d 100644
--- a/src/browser/BrowserSettings.h
+++ b/src/browser/BrowserSettings.h
@@ -59,7 +59,7 @@ public:
bool useCustomProxy();
void setUseCustomProxy(bool enabled);
QString customProxyLocation();
- void setCustomProxyLocation(QString location);
+ void setCustomProxyLocation(const QString& location);
bool updateBinaryPath();
void setUpdateBinaryPath(bool enabled);
bool chromeSupport();
@@ -98,11 +98,11 @@ public:
bool advancedMode();
void setAdvancedMode(bool advancedMode);
QString passwordExcludedChars();
- void setPasswordExcludedChars(QString chars);
+ void setPasswordExcludedChars(const QString& chars);
int passPhraseWordCount();
void setPassPhraseWordCount(int wordCount);
QString passPhraseWordSeparator();
- void setPassPhraseWordSeparator(QString separator);
+ void setPassPhraseWordSeparator(const QString& separator);
int generatorType();
void setGeneratorType(int type);
bool passwordEveryGroup();
@@ -114,7 +114,7 @@ public:
PasswordGenerator::CharClasses passwordCharClasses();
PasswordGenerator::GeneratorFlags passwordGeneratorFlags();
QString generatePassword();
- void updateBinaryPaths(QString customProxyLocation = QString());
+ void updateBinaryPaths(const QString& customProxyLocation = QString());
bool checkIfProxyExists(QString& path);
private:
diff --git a/src/cli/Clip.cpp b/src/cli/Clip.cpp
index 2268c6624..a9135eff4 100644
--- a/src/cli/Clip.cpp
+++ b/src/cli/Clip.cpp
@@ -71,7 +71,7 @@ int Clip::execute(const QStringList& arguments)
return clipEntry(db, args.at(1), args.value(2));
}
-int Clip::clipEntry(Database* database, QString entryPath, QString timeout)
+int Clip::clipEntry(Database* database, const QString& entryPath, const QString& timeout)
{
TextStream err(Utils::STDERR);
diff --git a/src/cli/Clip.h b/src/cli/Clip.h
index e94231236..929ddf678 100644
--- a/src/cli/Clip.h
+++ b/src/cli/Clip.h
@@ -26,7 +26,7 @@ public:
Clip();
~Clip();
int execute(const QStringList& arguments);
- int clipEntry(Database* database, QString entryPath, QString timeout);
+ int clipEntry(Database* database, const QString& entryPath, const QString& timeout);
};
#endif // KEEPASSXC_CLIP_H
diff --git a/src/cli/Command.cpp b/src/cli/Command.cpp
index c85e5d95d..a95676ff0 100644
--- a/src/cli/Command.cpp
+++ b/src/cli/Command.cpp
@@ -71,7 +71,7 @@ void populateCommands()
}
}
-Command* Command::getCommand(QString commandName)
+Command* Command::getCommand(const QString& commandName)
{
populateCommands();
if (commands.contains(commandName)) {
diff --git a/src/cli/Command.h b/src/cli/Command.h
index 7ad49440a..4e4e076de 100644
--- a/src/cli/Command.h
+++ b/src/cli/Command.h
@@ -35,7 +35,7 @@ public:
QString getDescriptionLine();
static QList<Command*> getCommands();
- static Command* getCommand(QString commandName);
+ static Command* getCommand(const QString& commandName);
};
#endif // KEEPASSXC_COMMAND_H
diff --git a/src/core/CsvParser.cpp b/src/core/CsvParser.cpp
index a66c919b2..e545d1db4 100644
--- a/src/core/CsvParser.cpp
+++ b/src/core/CsvParser.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2016 Enrico Mariotti <enricomariotti@yahoo.it>
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
*
@@ -327,7 +327,7 @@ bool CsvParser::isText(QChar c) const
return !((isCRLF(c)) || (isSeparator(c)));
}
-bool CsvParser::isEmptyRow(CsvRow row) const
+bool CsvParser::isEmptyRow(const CsvRow& row) const
{
CsvRow::const_iterator it = row.constBegin();
for (; it != row.constEnd(); ++it)
@@ -414,7 +414,7 @@ int CsvParser::getCsvRows() const
return m_table.size();
}
-void CsvParser::appendStatusMsg(QString s, bool isCritical)
+void CsvParser::appendStatusMsg(const QString& s, bool isCritical)
{
m_statusMsg += QObject::tr("%1: (row, col) %2,%3").arg(s, m_currRow, m_currCol).append("\n");
m_isGood = !isCritical;
diff --git a/src/core/CsvParser.h b/src/core/CsvParser.h
index 323023114..d90e8300a 100644
--- a/src/core/CsvParser.h
+++ b/src/core/CsvParser.h
@@ -83,7 +83,7 @@ private:
bool isCRLF(const QChar& c) const;
bool isSpace(const QChar& c) const;
bool isTab(const QChar& c) const;
- bool isEmptyRow(CsvRow row) const;
+ bool isEmptyRow(const CsvRow& row) const;
bool parseFile();
void parseRecord();
void parseField(CsvRow& row);
@@ -96,7 +96,7 @@ private:
void clear();
bool skipEndline();
void skipLine();
- void appendStatusMsg(QString s, bool isCritical = false);
+ void appendStatusMsg(const QString& s, bool isCritical = false);
};
#endif // CSVPARSER_H
diff --git a/src/core/Database.cpp b/src/core/Database.cpp
index 5116fd199..693b9c549 100644
--- a/src/core/Database.cpp
+++ b/src/core/Database.cpp
@@ -315,7 +315,7 @@ void Database::setCompressionAlgo(Database::CompressionAlgorithm algo)
* @param updateTransformSalt true to update the transform salt
* @return true on success
*/
-bool Database::setKey(QSharedPointer<const CompositeKey> key, bool updateChangedTime, bool updateTransformSalt)
+bool Database::setKey(const QSharedPointer<const CompositeKey>& key, bool updateChangedTime, bool updateTransformSalt)
{
if (!key) {
m_data.key.reset();
@@ -354,7 +354,7 @@ bool Database::hasKey() const
return m_data.hasKey;
}
-bool Database::verifyKey(QSharedPointer<CompositeKey> key) const
+bool Database::verifyKey(const QSharedPointer<CompositeKey>& key) const
{
Q_ASSERT(hasKey());
@@ -501,7 +501,7 @@ Database* Database::openDatabaseFile(const QString& fileName, QSharedPointer<con
return db;
}
-Database* Database::unlockFromStdin(QString databaseFilename, QString keyFilename, FILE* outputDescriptor, FILE* errorDescriptor)
+Database* Database::unlockFromStdin(const QString& databaseFilename, const QString& keyFilename, FILE* outputDescriptor, FILE* errorDescriptor)
{
auto compositeKey = QSharedPointer<CompositeKey>::create();
QTextStream out(outputDescriptor);
@@ -553,7 +553,7 @@ Database* Database::unlockFromStdin(QString databaseFilename, QString keyFilenam
* @param backup Backup the existing database file, if exists
* @return error string, if any
*/
-QString Database::saveToFile(QString filePath, bool atomic, bool backup)
+QString Database::saveToFile(const QString& filePath, bool atomic, bool backup)
{
QString error;
if (atomic) {
@@ -633,7 +633,7 @@ QString Database::writeDatabase(QIODevice* device)
* @param filePath Path to the file to backup
* @return
*/
-bool Database::backupDatabase(QString filePath)
+bool Database::backupDatabase(const QString& filePath)
{
QString backupFilePath = filePath;
auto re = QRegularExpression("\\.kdbx$|(?<!\\.kdbx)$", QRegularExpression::CaseInsensitiveOption);
@@ -652,7 +652,7 @@ void Database::setKdf(QSharedPointer<Kdf> kdf)
m_data.kdf = std::move(kdf);
}
-bool Database::changeKdf(QSharedPointer<Kdf> kdf)
+bool Database::changeKdf(const QSharedPointer<Kdf>& kdf)
{
kdf->randomizeSeed();
QByteArray transformedMasterKey;
diff --git a/src/core/Database.h b/src/core/Database.h
index 7108ded31..692444f4d 100644
--- a/src/core/Database.h
+++ b/src/core/Database.h
@@ -110,9 +110,9 @@ public:
void setCipher(const QUuid& cipher);
void setCompressionAlgo(Database::CompressionAlgorithm algo);
void setKdf(QSharedPointer<Kdf> kdf);
- bool setKey(QSharedPointer<const CompositeKey> key, bool updateChangedTime = true, bool updateTransformSalt = false);
+ bool setKey(const QSharedPointer<const CompositeKey>& key, bool updateChangedTime = true, bool updateTransformSalt = false);
bool hasKey() const;
- bool verifyKey(QSharedPointer<CompositeKey> key) const;
+ bool verifyKey(const QSharedPointer<CompositeKey>& key) const;
QVariantMap& publicCustomData();
const QVariantMap& publicCustomData() const;
void setPublicCustomData(const QVariantMap& customData);
@@ -121,17 +121,17 @@ public:
void emptyRecycleBin();
void setEmitModified(bool value);
void markAsModified();
- QString saveToFile(QString filePath, bool atomic = true, bool backup = false);
+ QString saveToFile(const QString& filePath, bool atomic = true, bool backup = false);
/**
* Returns a unique id that is only valid as long as the Database exists.
*/
const QUuid& uuid();
- bool changeKdf(QSharedPointer<Kdf> kdf);
+ bool changeKdf(const QSharedPointer<Kdf>& kdf);
static Database* databaseByUuid(const QUuid& uuid);
static Database* openDatabaseFile(const QString& fileName, QSharedPointer<const CompositeKey> key);
- static Database* unlockFromStdin(QString databaseFilename, QString keyFilename = {},
+ static Database* unlockFromStdin(const QString& databaseFilename, const QString& keyFilename = {},
FILE* outputDescriptor = stdout, FILE* errorDescriptor = stderr);
signals:
@@ -156,7 +156,7 @@ private:
void createRecycleBin();
QString writeDatabase(QIODevice* device);
- bool backupDatabase(QString filePath);
+ bool backupDatabase(const QString& filePath);
Metadata* const m_metadata;
Group* m_rootGroup;
diff --git a/src/core/EntrySearcher.cpp b/src/core/EntrySearcher.cpp
index 820646a98..3413f1cd0 100644
--- a/src/core/EntrySearcher.cpp
+++ b/src/core/EntrySearcher.cpp
@@ -34,12 +34,12 @@ EntrySearcher::searchEntries(const QString& searchTerm, const Group* group, Qt::
{
QList<Entry*> searchResult;
- const QList<Entry*> entryList = group->entries();
+ const QList<Entry*>& entryList = group->entries();
for (Entry* entry : entryList) {
searchResult.append(matchEntry(searchTerm, entry, caseSensitivity));
}
- const QList<Group*> children = group->children();
+ const QList<Group*>& children = group->children();
for (Group* childGroup : children) {
if (childGroup->searchingEnabled() != Group::Disable) {
if (matchGroup(searchTerm, childGroup, caseSensitivity)) {
diff --git a/src/core/Group.cpp b/src/core/Group.cpp
index 72f2490a0..4b1d11ab0 100644
--- a/src/core/Group.cpp
+++ b/src/core/Group.cpp
@@ -563,7 +563,7 @@ Entry* Group::findEntryByUuid(const QUuid& uuid) const
return nullptr;
}
-Entry* Group::findEntryByPath(QString entryPath)
+Entry* Group::findEntryByPath(const QString& entryPath)
{
if (entryPath.isEmpty()) {
return nullptr;
@@ -578,7 +578,7 @@ Entry* Group::findEntryByPath(QString entryPath)
return findEntryByPathRecursive(normalizedEntryPath, "/");
}
-Entry* Group::findEntryByPathRecursive(QString entryPath, QString basePath)
+Entry* Group::findEntryByPathRecursive(const QString& entryPath, const QString& basePath)
{
// Return the first entry that matches the full path OR if there is no leading
// slash, return the first entry title that matches
@@ -599,7 +599,7 @@ Entry* Group::findEntryByPathRecursive(QString entryPath, QString basePath)
return nullptr;
}
-Group* Group::findGroupByPath(QString groupPath)
+Group* Group::findGroupByPath(const QString& groupPath)
{
// normalize the groupPath by adding missing front and rear slashes. once.
QString normalizedGroupPath;
@@ -614,7 +614,7 @@ Group* Group::findGroupByPath(QString groupPath)
return findGroupByPathRecursive(normalizedGroupPath, "/");
}
-Group* Group::findGroupByPathRecursive(QString groupPath, QString basePath)
+Group* Group::findGroupByPathRecursive(const QString& groupPath, const QString& basePath)
{
// paths must be normalized
Q_ASSERT(groupPath.startsWith("/") && groupPath.endsWith("/"));
@@ -926,7 +926,7 @@ bool Group::resolveAutoTypeEnabled() const
}
}
-QStringList Group::locate(QString locateTerm, QString currentPath) const
+QStringList Group::locate(const QString& locateTerm, const QString& currentPath) const
{
// TODO: Replace with EntrySearcher
QStringList response;
@@ -950,7 +950,7 @@ QStringList Group::locate(QString locateTerm, QString currentPath) const
return response;
}
-Entry* Group::addEntryWithPath(QString entryPath)
+Entry* Group::addEntryWithPath(const QString& entryPath)
{
if (entryPath.isEmpty() || findEntryByPath(entryPath)) {
return nullptr;
diff --git a/src/core/Group.h b/src/core/Group.h
index 3a9332c8e..da6994d2a 100644
--- a/src/core/Group.h
+++ b/src/core/Group.h
@@ -115,11 +115,11 @@ public:
Group* findChildByName(const QString& name);
Entry* findEntryByUuid(const QUuid& uuid) const;
- Entry* findEntryByPath(QString entryPath);
+ Entry* findEntryByPath(const QString& entryPath);
Group* findGroupByUuid(const QUuid& uuid);
- Group* findGroupByPath(QString groupPath);
- QStringList locate(QString locateTerm, QString currentPath = {"/"}) const;
- Entry* addEntryWithPath(QString entryPath);
+ Group* findGroupByPath(const QString& groupPath);
+ QStringList locate(const QString& locateTerm, const QString& currentPath = {"/"}) const;
+ Entry* addEntryWithPath(const QString& entryPath);
void setUuid(const QUuid& uuid);
void setName(const QString& name);
void setNotes(const QString& notes);
@@ -190,8 +190,8 @@ private:
void cleanupParent();
void recCreateDelObjects();
- Entry* findEntryByPathRecursive(QString entryPath, QString basePath);
- Group* findGroupByPathRecursive(QString groupPath, QString basePath);
+ Entry* findEntryByPathRecursive(const QString& entryPath, const QString& basePath);
+ Group* findGroupByPathRecursive(const QString& groupPath, const QString& basePath);
QPointer<Database> m_db;
QUuid m_uuid;
diff --git a/src/core/PasswordGenerator.cpp b/src/core/PasswordGenerator.cpp
index 3dbcdaad8..124b99896 100644
--- a/src/core/PasswordGenerator.cpp
+++ b/src/core/PasswordGenerator.cpp
@@ -31,7 +31,7 @@ PasswordGenerator::PasswordGenerator()
{
}
-double PasswordGenerator::calculateEntropy(QString password)
+double PasswordGenerator::calculateEntropy(const QString& password)
{
return ZxcvbnMatch(password.toLatin1(), 0, 0);
}
diff --git a/src/core/PasswordGenerator.h b/src/core/PasswordGenerator.h
index cb6402d0f..7bfdddd69 100644
--- a/src/core/PasswordGenerator.h
+++ b/src/core/PasswordGenerator.h
@@ -57,7 +57,7 @@ public:
public:
PasswordGenerator();
- double calculateEntropy(QString password);
+ double calculateEntropy(const QString& password);
void setLength(int length);
void setCharClasses(const CharClasses& classes);
void setFlags(const GeneratorFlags& flags);
diff --git a/src/format/CsvExporter.cpp b/src/format/CsvExporter.cpp
index c444afe23..67e6a44fc 100644
--- a/src/format/CsvExporter.cpp
+++ b/src/format/CsvExporter.cpp
@@ -64,7 +64,7 @@ bool CsvExporter::writeGroup(QIODevice* device, const Group* group, QString grou
}
groupPath.append(group->name());
- const QList<Entry*> entryList = group->entries();
+ const QList<Entry*>& entryList = group->entries();
for (const Entry* entry : entryList) {
QString line;
@@ -83,7 +83,7 @@ bool CsvExporter::writeGroup(QIODevice* device, const Group* group, QString grou
}
}
- const QList<Group*> children = group->children();
+ const QList<Group*>& children = group->children();
for (const Group* child : children) {
if (!writeGroup(device, child, groupPath)) {
return false;
diff --git a/src/format/KeePass2.cpp b/src/format/KeePass2.cpp
index 9c0714484..639255d27 100644
--- a/src/format/KeePass2.cpp
+++ b/src/format/KeePass2.cpp
@@ -59,7 +59,7 @@ const QList<QPair<QUuid, QString>> KeePass2::KDFS{
qMakePair(KeePass2::KDF_AES_KDBX3, QObject::tr("AES-KDF (KDBX 3.1)"))
};
-QByteArray KeePass2::hmacKey(QByteArray masterSeed, QByteArray transformedMasterKey)
+QByteArray KeePass2::hmacKey(const QByteArray& masterSeed, const QByteArray& transformedMasterKey)
{
CryptoHash hmacKeyHash(CryptoHash::Sha512);
hmacKeyHash.addData(masterSeed);
@@ -98,7 +98,7 @@ QSharedPointer<Kdf> KeePass2::kdfFromParameters(const QVariantMap& p)
return kdf;
}
-QVariantMap KeePass2::kdfToParameters(QSharedPointer<Kdf> kdf)
+QVariantMap KeePass2::kdfToParameters(const QSharedPointer<Kdf>& kdf)
{
return kdf->writeParameters();
}
diff --git a/src/format/KeePass2.h b/src/format/KeePass2.h
index 02fe635ca..195ce8c2b 100644
--- a/src/format/KeePass2.h
+++ b/src/format/KeePass2.h
@@ -126,9 +126,9 @@ extern const QList<QPair<QUuid, QString>> KDFS;
ByteArray = 0x42
};
-QByteArray hmacKey(QByteArray masterSeed, QByteArray transformedMasterKey);
+QByteArray hmacKey(const QByteArray& masterSeed, const QByteArray& transformedMasterKey);
QSharedPointer<Kdf> kdfFromParameters(const QVariantMap& p);
-QVariantMap kdfToParameters(QSharedPointer<Kdf> kdf);
+QVariantMap kdfToParameters(const QSharedPointer<Kdf>& kdf);
QSharedPointer<Kdf> uuidToKdf(const QUuid& uuid);
ProtectedStreamAlgo idToProtectedStreamAlgo(quint32 id);
diff --git a/src/gui/EditWidgetIcons.cpp b/src/gui/EditWidgetIcons.cpp
index 0555359d8..f2c320dc9 100644
--- a/src/gui/EditWidgetIcons.cpp
+++ b/src/gui/EditWidgetIcons.cpp
@@ -176,7 +176,7 @@ namespace {
// Try to get the 2nd level domain of the host part of a QUrl. For example,
// "foo.bar.example.com" would become "example.com", and "foo.bar.example.co.uk"
// would become "example.co.uk".
- QString getSecondLevelDomain(QUrl url)
+ QString getSecondLevelDomain(const QUrl& url)
{
QString fqdn = url.host();
fqdn.truncate(fqdn.length() - url.topLevelDomain().length());
@@ -185,7 +185,7 @@ namespace {
return newdom;
}
- QUrl convertVariantToUrl(QVariant var)
+ QUrl convertVariantToUrl(const QVariant& var)
{
QUrl url;
if (var.canConvert<QUrl>())
diff --git a/src/gui/FileDialog.cpp b/src/gui/FileDialog.cpp
index 5bccc4af3..b063d62f3 100644
--- a/src/gui/FileDialog.cpp
+++ b/src/gui/FileDialog.cpp
@@ -178,7 +178,7 @@ FileDialog::FileDialog()
{
}
-void FileDialog::saveLastDir(QString dir)
+void FileDialog::saveLastDir(const QString& dir)
{
if (!dir.isEmpty() && !m_forgetLastDir) {
config()->set("LastDir", QFileInfo(dir).absolutePath());
diff --git a/src/gui/FileDialog.h b/src/gui/FileDialog.h
index 4862dcfda..83b151ec9 100644
--- a/src/gui/FileDialog.h
+++ b/src/gui/FileDialog.h
@@ -65,7 +65,7 @@ private:
QString m_nextDirName;
bool m_forgetLastDir = false;
- void saveLastDir(QString);
+ void saveLastDir(const QString&);
static FileDialog* m_instance;
diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp
index 9efe0c273..8f0c23044 100644
--- a/src/gui/MainWindow.cpp
+++ b/src/gui/MainWindow.cpp
@@ -673,7 +673,7 @@ void MainWindow::switchToOpenDatabase()
switchToDatabases();
}
-void MainWindow::switchToDatabaseFile(QString file)
+void MainWindow::switchToDatabaseFile(const QString& file)
{
m_ui->tabWidget->openDatabase(file);
switchToDatabases();
diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h
index d83b4a1ff..174e47564 100644
--- a/src/gui/MainWindow.h
+++ b/src/gui/MainWindow.h
@@ -90,7 +90,7 @@ private slots:
void switchToPasswordGen(bool enabled);
void switchToNewDatabase();
void switchToOpenDatabase();
- void switchToDatabaseFile(QString file);
+ void switchToDatabaseFile(const QString& file);
void switchToKeePass1Database();
void switchToCsvImport();
void closePasswordGen();
diff --git a/src/gui/PasswordEdit.cpp b/src/gui/PasswordEdit.cpp
index 33d022176..02067ccc4 100644
--- a/src/gui/PasswordEdit.cpp
+++ b/src/gui/PasswordEdit.cpp
@@ -98,7 +98,7 @@ void PasswordEdit::updateStylesheet()
setStyleSheet(stylesheet);
}
-void PasswordEdit::autocompletePassword(QString password)
+void PasswordEdit::autocompletePassword(const QString& password)
{
if (config()->get("security/passwordsrepeat").toBool() && echoMode() == QLineEdit::Normal) {
setText(password);
diff --git a/src/gui/PasswordEdit.h b/src/gui/PasswordEdit.h
index 5976347e6..222376d09 100644
--- a/src/gui/PasswordEdit.h
+++ b/src/gui/PasswordEdit.h
@@ -41,7 +41,7 @@ signals:
private slots:
void updateStylesheet();
- void autocompletePassword(QString password);
+ void autocompletePassword(const QString& password);
private:
bool passwordsEqual() const;
diff --git a/src/gui/csvImport/CsvImportWidget.cpp b/src/gui/csvImport/CsvImportWidget.cpp
index 4cb219a77..3b623f73d 100644
--- a/src/gui/csvImport/CsvImportWidget.cpp
+++ b/src/gui/csvImport/CsvImportWidget.cpp
@@ -315,7 +315,7 @@ void CsvImportWidget::setRootGroup()
m_db->rootGroup()->setName("Root");
}
-Group* CsvImportWidget::splitGroups(QString label)
+Group* CsvImportWidget::splitGroups(const QString& label)
{
// extract group names from nested path provided in "label"
Group* current = m_db->rootGroup();
@@ -345,7 +345,7 @@ Group* CsvImportWidget::splitGroups(QString label)
return current;
}
-Group* CsvImportWidget::hasChildren(Group* current, QString groupName)
+Group* CsvImportWidget::hasChildren(Group* current, const QString& groupName)
{
// returns the group whose name is "groupName" and is child of "current" group
for (Group* group : current->children()) {
diff --git a/src/gui/csvImport/CsvImportWidget.h b/src/gui/csvImport/CsvImportWidget.h
index cd13836f0..a5807eefd 100644
--- a/src/gui/csvImport/CsvImportWidget.h
+++ b/src/gui/csvImport/CsvImportWidget.h
@@ -68,8 +68,8 @@ private:
QStringList m_fieldSeparatorList;
void configParser();
void updateTableview();
- Group* splitGroups(QString label);
- Group* hasChildren(Group* current, QString groupName);
+ Group* splitGroups(const QString& label);
+ Group* hasChildren(Group* current, const QString& groupName);
QString formatStatusText() const;
};
diff --git a/src/gui/entry/AutoTypeMatchModel.cpp b/src/gui/entry/AutoTypeMatchModel.cpp
index 1a6a6ba3b..197b3cd96 100644
--- a/src/gui/entry/AutoTypeMatchModel.cpp
+++ b/src/gui/entry/AutoTypeMatchModel.cpp
@@ -37,7 +37,7 @@ AutoTypeMatch AutoTypeMatchModel::matchFromIndex(const QModelIndex& index) const
return m_matches.at(index.row());
}
-QModelIndex AutoTypeMatchModel::indexFromMatch(AutoTypeMatch match) const
+QModelIndex AutoTypeMatchModel::indexFromMatch(const AutoTypeMatch& match) const
{
int row = m_matches.indexOf(match);
Q_ASSERT(row != -1);
diff --git a/src/gui/entry/AutoTypeMatchModel.h b/src/gui/entry/AutoTypeMatchModel.h
index 791dbc3df..58b89465b 100644
--- a/src/gui/entry/AutoTypeMatchModel.h
+++ b/src/gui/entry/AutoTypeMatchModel.h
@@ -41,7 +41,7 @@ public:
explicit AutoTypeMatchModel(QObject* parent = nullptr);
AutoTypeMatch matchFromIndex(const QModelIndex& index) const;
- QModelIndex indexFromMatch(AutoTypeMatch match) const;
+ QModelIndex indexFromMatch(const AutoTypeMatch& match) const;
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
diff --git a/src/gui/entry/AutoTypeMatchView.cpp b/src/gui/entry/AutoTypeMatchView.cpp
index 2750082d8..0eb257237 100644
--- a/src/gui/entry/AutoTypeMatchView.cpp
+++ b/src/gui/entry/AutoTypeMatchView.cpp
@@ -98,7 +98,7 @@ AutoTypeMatch AutoTypeMatchView::currentMatch()
return AutoTypeMatch();
}
-void AutoTypeMatchView::setCurrentMatch(AutoTypeMatch match)
+void AutoTypeMatchView::setCurrentMatch(const AutoTypeMatch& match)
{
selectionModel()->setCurrentIndex(m_sortModel->mapFromSource(m_model->indexFromMatch(match)),
QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
diff --git a/src/gui/entry/AutoTypeMatchView.h b/src/gui/entry/AutoTypeMatchView.h
index 14ad9ea2a..b9f3f3aa5 100644
--- a/src/gui/entry/AutoTypeMatchView.h
+++ b/src/gui/entry/AutoTypeMatchView.h
@@ -34,7 +34,7 @@ class AutoTypeMatchView : public QTreeView
public:
explicit AutoTypeMatchView(QWidget* parent = nullptr);
AutoTypeMatch currentMatch();
- void setCurrentMatch(AutoTypeMatch match);
+ void setCurrentMatch(const AutoTypeMatch& match);
AutoTypeMatch matchFromIndex(const QModelIndex& index);
void setMatchList(const QList<AutoTypeMatch>& matches);
void setFirstMatchActive();
diff --git a/src/gui/entry/EntryHistoryModel.cpp b/src/gui/entry/EntryHistoryModel.cpp
index aaec3de62..2506e06d7 100644
--- a/src/gui/entry/EntryHistoryModel.cpp
+++ b/src/gui/entry/EntryHistoryModel.cpp
@@ -54,7 +54,7 @@ QVariant EntryHistoryModel::data(const QModelIndex& index, int role) const
if (role == Qt::DisplayRole || role == Qt::UserRole) {
Entry* entry = entryFromIndex(index);
- TimeInfo timeInfo = entry->timeInfo();
+ const TimeInfo& timeInfo = entry->timeInfo();
QDateTime lastModificationLocalTime = timeInfo.lastModificationTime().toLocalTime();
switch (index.column()) {
case 0:
diff --git a/src/keys/CompositeKey.cpp b/src/keys/CompositeKey.cpp
index 4fca7d320..10e86318b 100644
--- a/src/keys/CompositeKey.cpp
+++ b/src/keys/CompositeKey.cpp
@@ -153,7 +153,7 @@ bool CompositeKey::challenge(const QByteArray& seed, QByteArray& result) const
*
* @param key the key
*/
-void CompositeKey::addKey(QSharedPointer<Key> key)
+void CompositeKey::addKey(const QSharedPointer<Key>& key)
{
m_keys.append(key);
}
@@ -173,7 +173,7 @@ const QList<QSharedPointer<Key>>& CompositeKey::keys() const
*
* @param key the key
*/
-void CompositeKey::addChallengeResponseKey(QSharedPointer<ChallengeResponseKey> key)
+void CompositeKey::addChallengeResponseKey(const QSharedPointer<ChallengeResponseKey>& key)
{
m_challengeResponseKeys.append(key);
}
diff --git a/src/keys/CompositeKey.h b/src/keys/CompositeKey.h
index 43c624acb..f32f3a1a1 100644
--- a/src/keys/CompositeKey.h
+++ b/src/keys/CompositeKey.h
@@ -42,10 +42,10 @@ public:
Q_REQUIRED_RESULT bool transform(const Kdf& kdf, QByteArray& result) const;
bool challenge(const QByteArray& seed, QByteArray& result) const;
- void addKey(QSharedPointer<Key> key);
+ void addKey(const QSharedPointer<Key>& key);
const QList<QSharedPointer<Key>>& keys() const;
- void addChallengeResponseKey(QSharedPointer<ChallengeResponseKey> key);\
+ void addChallengeResponseKey(const QSharedPointer<ChallengeResponseKey>& key);\
const QList<QSharedPointer<ChallengeResponseKey>>& challengeResponseKeys() const;
private:
diff --git a/src/streams/HmacBlockStream.cpp b/src/streams/HmacBlockStream.cpp
index 780db98c1..01d9ba7cd 100644
--- a/src/streams/HmacBlockStream.cpp
+++ b/src/streams/HmacBlockStream.cpp
@@ -245,7 +245,7 @@ QByteArray HmacBlockStream::getCurrentHmacKey() const
return getHmacKey(m_blockIndex, m_key);
}
-QByteArray HmacBlockStream::getHmacKey(quint64 blockIndex, QByteArray key)
+QByteArray HmacBlockStream::getHmacKey(quint64 blockIndex, const QByteArray& key)
{
Q_ASSERT(key.size() == 64);
QByteArray indexBytes = Endian::sizedIntToBytes<quint64>(blockIndex, ByteOrder);
diff --git a/src/streams/HmacBlockStream.h b/src/streams/HmacBlockStream.h
index c10c96746..a2ad062e3 100644
--- a/src/streams/HmacBlockStream.h
+++ b/src/streams/HmacBlockStream.h
@@ -34,7 +34,7 @@ public:
bool reset() override;
void close() override;
- static QByteArray getHmacKey(quint64 blockIndex, QByteArray key);
+ static QByteArray getHmacKey(quint64 blockIndex, const QByteArray& key);
bool atEnd() const override;
diff --git a/src/totp/totp.cpp b/src/totp/totp.cpp
index bc66fffa4..f1146441a 100644
--- a/src/totp/totp.cpp
+++ b/src/totp/totp.cpp
@@ -97,7 +97,7 @@ QSharedPointer<Totp::Settings> Totp::createSettings(const QString& key, const ui
});
}
-QString Totp::writeSettings(const QSharedPointer<Totp::Settings> settings, const QString& title, const QString& username, bool forceOtp)
+QString Totp::writeSettings(const QSharedPointer<Totp::Settings>& settings, const QString& title, const QString& username, bool forceOtp)
{
if (settings.isNull()) {
return {};
@@ -127,7 +127,7 @@ QString Totp::writeSettings(const QSharedPointer<Totp::Settings> settings, const
return QString("%1;%2").arg(settings->step).arg(settings->digits);
}
-QString Totp::generateTotp(const QSharedPointer<Totp::Settings> settings, const quint64 time)
+QString Totp::generateTotp(const QSharedPointer<Totp::Settings>& settings, const quint64 time)
{
Q_ASSERT(!settings.isNull());
if (settings.isNull()) {
@@ -194,7 +194,7 @@ Totp::Encoder& Totp::steamEncoder()
return getEncoderByShortName("S");
}
-Totp::Encoder& Totp::getEncoderByShortName(QString shortName)
+Totp::Encoder& Totp::getEncoderByShortName(const QString& shortName)
{
for (auto& encoder : encoders) {
if (encoder.shortName == shortName) {
@@ -204,7 +204,7 @@ Totp::Encoder& Totp::getEncoderByShortName(QString shortName)
return defaultEncoder();
}
-Totp::Encoder& Totp::getEncoderByName(QString name)
+Totp::Encoder& Totp::getEncoderByName(const QString& name)
{
for (auto& encoder : encoders) {
if (encoder.name == name) {
diff --git a/src/totp/totp.h b/src/totp/totp.h
index ba11ba2b0..0697281bf 100644
--- a/src/totp/totp.h
+++ b/src/totp/totp.h
@@ -60,15 +60,15 @@ static const QString ATTRIBUTE_SETTINGS = "TOTP Settings";
QSharedPointer<Totp::Settings> parseSettings(const QString& rawSettings, const QString& key = {});
QSharedPointer<Totp::Settings> createSettings(const QString& key, const uint digits, const uint step,
const QString& encoderShortName = {});
-QString writeSettings(const QSharedPointer<Totp::Settings> settings, const QString& title = {},
+QString writeSettings(const QSharedPointer<Totp::Settings>& settings, const QString& title = {},
const QString& username = {}, bool forceOtp = false);
-QString generateTotp(const QSharedPointer<Totp::Settings> settings, const quint64 time = 0ull);
+QString generateTotp(const QSharedPointer<Totp::Settings>& settings, const quint64 time = 0ull);
Encoder& defaultEncoder();
Encoder& steamEncoder();
-Encoder& getEncoderByShortName(QString shortName);
-Encoder& getEncoderByName(QString name);
+Encoder& getEncoderByShortName(const QString& shortName);
+Encoder& getEncoderByName(const QString& name);
}
#endif // QTOTP_H