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.
This commit is contained in:
Gianluca Recchia 2018-10-28 12:49:32 +01:00
parent a67a574b89
commit da9afd3f6f
No known key found for this signature in database
GPG key ID: 3C2B4128D9A1F218
40 changed files with 90 additions and 90 deletions

View file

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