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:
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user