From 1696ad19fc409e69e6c473d107e0b0af2ed1f009 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Sat, 4 Jul 2015 22:13:31 +0200 Subject: [PATCH] Remove all the "no error" error messages They are kind of pointless because, really, they never should be visible to the user. If there is no error we shouldn't show an error message and if there is an error we should show a proper error message. Especially during bunch executions of SQL statements by calling DBBrowserDB::executeSQL() (like when importing a huge CSV file) this avoids a whole bunch of string copy operations and calls to tr() and should therefore increase the performance a bit, too. --- src/sqlitedb.cpp | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/sqlitedb.cpp b/src/sqlitedb.cpp index 94e345d4..1e73861b 100644 --- a/src/sqlitedb.cpp +++ b/src/sqlitedb.cpp @@ -69,8 +69,6 @@ bool DBBrowserDB::open(const QString& db) { if (isOpen()) close(); - lastErrorMessage = tr("no error"); - isEncrypted = false; // Get encryption settings for database file @@ -298,8 +296,6 @@ bool DBBrowserDB::create ( const QString & db) if (isOpen()) close(); - lastErrorMessage = tr("no error"); - // read encoding from settings and open with sqlite3_open for utf8 // and sqlite3_open16 for utf16 QSettings settings(QApplication::organizationName(), QApplication::organizationName()); @@ -547,19 +543,15 @@ bool DBBrowserDB::dump(const QString& filename, bool DBBrowserDB::executeSQL ( const QString & statement, bool dirtyDB, bool logsql) { char *errmsg; - bool ok = false; if (!isOpen()) return false; if (logsql) logSQL(statement, kLogMsg_App); if (dirtyDB) setRestorePoint(); - if (SQLITE_OK == sqlite3_exec(_db, statement.toUtf8(), NULL, NULL, &errmsg)) - ok = true; - if(ok) + if (SQLITE_OK == sqlite3_exec(_db, statement.toUtf8(), NULL, NULL, &errmsg)) { - lastErrorMessage = tr("no error"); return true; } else { lastErrorMessage = QString("%1 (%2)").arg(QString::fromUtf8(errmsg)).arg(statement); @@ -783,7 +775,6 @@ bool DBBrowserDB::deleteRecord(const QString& table, const QString& rowid) { if (!isOpen()) return false; bool ok = false; - lastErrorMessage = QString("no error"); QString statement = QString("DELETE FROM `%1` WHERE `%2`='%3';").arg(table).arg(getObjectByName(table).table.rowidColumn()).arg(rowid); if(executeSQL(statement)) @@ -798,8 +789,6 @@ bool DBBrowserDB::updateRecord(const QString& table, const QString& column, cons { if (!isOpen()) return false; - lastErrorMessage = QString("no error"); - QString sql = QString("UPDATE `%1` SET `%2`=? WHERE `%3`='%4';").arg(table).arg(column).arg(getObjectByName(table).table.rowidColumn()).arg(rowid); logSQL(sql, kLogMsg_App); @@ -1092,7 +1081,6 @@ void DBBrowserDB::updateSchema( ) sqlite3_stmt *vm; const char *tail; int err=0; - lastErrorMessage = tr("no error"); objMap.clear();