From 9e645db1a89dac14fcbc25d0922a08b636bbd2a5 Mon Sep 17 00:00:00 2001 From: eelke Date: Sun, 9 Dec 2018 21:10:35 +0100 Subject: [PATCH] Fixed some small details the analyzer was complaining about. --- core/QueuedBackgroundTask.cpp | 2 +- core/SqlLexer.cpp | 62 +++++++++++++++++------------------ core/SqlLexer.h | 2 +- pglab/BackupDialog.cpp | 6 ++-- pglab/BackupDialog.h | 2 +- pglab/BackupRestore.cpp | 2 +- pglab/CodeGenerator.cpp | 6 ++-- 7 files changed, 40 insertions(+), 42 deletions(-) diff --git a/core/QueuedBackgroundTask.cpp b/core/QueuedBackgroundTask.cpp index d7ed17e..57306a0 100644 --- a/core/QueuedBackgroundTask.cpp +++ b/core/QueuedBackgroundTask.cpp @@ -5,7 +5,7 @@ //{} QueuedBackgroundTask::QueuedBackgroundTask(CompletionFunction on_completion) - : m_completionFunction(on_completion) + : m_completionFunction(std::move(on_completion)) { setAutoDelete(false); } diff --git a/core/SqlLexer.cpp b/core/SqlLexer.cpp index 3a23dac..66cdf35 100644 --- a/core/SqlLexer.cpp +++ b/core/SqlLexer.cpp @@ -1,7 +1,7 @@ #include "SqlLexer.h" -SqlLexer::SqlLexer(const QString &block, LexerState currentstate) - : m_block(block) +SqlLexer::SqlLexer(QString block, LexerState currentstate) + : m_block(std::move(block)) , m_state(currentstate) {} @@ -207,21 +207,20 @@ bool SqlLexer::parseSingleQuotedString(int startpos, int &length, BasicTokenType tokentype = BasicTokenType::QuotedString; return true; } - else { - nextChar(); - if (c == '\'') { - // maybe end of string literal - if (peekChar() == '\'') { - // Nope, just double quote to escape quote - nextChar(); // eat it - } - else { - length = m_pos - startpos; - tokentype = BasicTokenType::QuotedString; - return true; - } - } - } + + nextChar(); + if (c == '\'') { + // maybe end of string literal + if (peekChar() == '\'') { + // Nope, just double quote to escape quote + nextChar(); // eat it + } + else { + length = m_pos - startpos; + tokentype = BasicTokenType::QuotedString; + return true; + } + } } } @@ -236,21 +235,20 @@ bool SqlLexer::parseDoubleQuotedIdentifier(int startpos, int &length, BasicToken tokentype = BasicTokenType::QuotedIdentifier; return true; } - else { - nextChar(); - if (c == '"') { - // maybe end of string literal - if (peekChar() == '"') { - // Nope, just double quote to escape quote - nextChar(); // eat it - } - else { - length = m_pos - startpos; - tokentype = BasicTokenType::QuotedIdentifier; - return true; - } - } - } + + nextChar(); + if (c == '"') { + // maybe end of string literal + if (peekChar() == '"') { + // Nope, just double quote to escape quote + nextChar(); // eat it + } + else { + length = m_pos - startpos; + tokentype = BasicTokenType::QuotedIdentifier; + return true; + } + } } } diff --git a/core/SqlLexer.h b/core/SqlLexer.h index 3641714..61e551c 100644 --- a/core/SqlLexer.h +++ b/core/SqlLexer.h @@ -37,7 +37,7 @@ public: class SqlLexer { public: - SqlLexer(const QString &block, LexerState currentstate); + SqlLexer(QString block, LexerState currentstate); QChar nextChar(); QChar peekChar(); /** diff --git a/pglab/BackupDialog.cpp b/pglab/BackupDialog.cpp index 797c62b..7c1fa9e 100644 --- a/pglab/BackupDialog.cpp +++ b/pglab/BackupDialog.cpp @@ -64,7 +64,7 @@ void BackupDialog::disconnectCurrentProcess() } -void BackupDialog::writeOutput(QString s) +void BackupDialog::writeOutput(const QString &s) { ui->stdOutput->appendPlainText(s); QScrollBar *bar = ui->stdOutput->verticalScrollBar(); @@ -153,7 +153,7 @@ void BackupDialog::setParams(QStringList &args) int format_index = ui->backupFormat->currentIndex(); auto format_model_base = ui->backupFormat->model(); - BackupFormatModel *bfm = dynamic_cast(format_model_base); + auto *bfm = dynamic_cast(format_model_base); if (bfm) { QVariant v = bfm->data(bfm->index(format_index, 1)); QString format("-F"); @@ -252,7 +252,7 @@ void BackupDialog::on_backupFormat_currentIndexChanged(int /*index*/) { int format_index = ui->backupFormat->currentIndex(); auto format_model_base = ui->backupFormat->model(); - BackupFormatModel *bfm = dynamic_cast(format_model_base); + auto *bfm = dynamic_cast(format_model_base); if (bfm) { QVariant v = bfm->data(bfm->index(format_index, 1)); QString format = v.toString(); diff --git a/pglab/BackupDialog.h b/pglab/BackupDialog.h index d35e82a..6ed5afa 100644 --- a/pglab/BackupDialog.h +++ b/pglab/BackupDialog.h @@ -28,7 +28,7 @@ private: QProcess *m_process = nullptr; ConnectionConfig m_config; - void writeOutput(QString s); + void writeOutput(const QString &s); void setParams(QStringList &args); private slots: diff --git a/pglab/BackupRestore.cpp b/pglab/BackupRestore.cpp index 5cbfe07..f26f01b 100644 --- a/pglab/BackupRestore.cpp +++ b/pglab/BackupRestore.cpp @@ -24,7 +24,7 @@ void setupEnvironment(const ConnectionConfig &cc) //--------------------------------------------------------------------------- -void Backup(QString dest_file_name) +void Backup(const QString &dest_file_name) { // QString command_line = "\"" + ExecutableDump + "\" "; diff --git a/pglab/CodeGenerator.cpp b/pglab/CodeGenerator.cpp index 227487e..dfc5b7e 100644 --- a/pglab/CodeGenerator.cpp +++ b/pglab/CodeGenerator.cpp @@ -23,9 +23,9 @@ CodeGenerator::~CodeGenerator() void CodeGenerator::Init(std::shared_ptr catalog, QString query, std::shared_ptr dbres) { - m_catalog = catalog; - m_query = query; - m_dbres = dbres; + m_catalog = std::move(catalog); + m_query = std::move(query); + m_dbres = std::move(dbres); generateCode();