From af9f6788daf6910d3727bf5a85cd88ebf0b93ba4 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Wed, 28 Aug 2019 20:13:43 +0200 Subject: [PATCH] core: Use QLatin1String in a few places It is recommended to use QLatin1String as an efficient wrapper around const char*. Use this in the places recently touched. --- src/core/sqlitestorage.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/core/sqlitestorage.cpp b/src/core/sqlitestorage.cpp index 893bd774..f56f914e 100644 --- a/src/core/sqlitestorage.cpp +++ b/src/core/sqlitestorage.cpp @@ -22,6 +22,8 @@ #include +#include + #include "network.h" #include "quassel.h" @@ -192,7 +194,7 @@ UserId SqliteStorage::addUser(const QString& user, const QString& password, cons lockForWrite(); safeExec(query); if (query.lastError().isValid() - && query.lastError().nativeErrorCode() == "19") { // user already exists - sadly 19 seems to be the general constraint violation error... + && query.lastError().nativeErrorCode() == QLatin1String{"19"}) { // user already exists - sadly 19 seems to be the general constraint violation error... db.rollback(); } else { @@ -1409,7 +1411,7 @@ bool SqliteStorage::renameBuffer(const UserId& user, const BufferId& bufferId, c error = query.lastError().isValid(); // unexepcted error occured (19 == constraint violation) - if (error && query.lastError().nativeErrorCode() != "19") { + if (error && query.lastError().nativeErrorCode() != QLatin1String{"19"}) { watchQuery(query); } else { @@ -1790,7 +1792,7 @@ bool SqliteStorage::logMessage(Message& msg) if (logMessageQuery.lastError().isValid()) { // constraint violation - must be NOT NULL constraint - probably the sender is missing... - if (logMessageQuery.lastError().nativeErrorCode() == "19") { + if (logMessageQuery.lastError().nativeErrorCode() == QLatin1String{"19"}) { QSqlQuery addSenderQuery(db); addSenderQuery.prepare(queryString("insert_sender")); addSenderQuery.bindValue(":sender", msg.sender()); @@ -2223,7 +2225,7 @@ bool SqliteStorage::safeExec(QSqlQuery& query, int retryCount) // SQLITE_BUSY 5 /* The database file is locked */ // SQLITE_LOCKED 6 /* A table in the database is locked */ - if (nativeErrorCode == "5" || nativeErrorCode == "6") { + if (nativeErrorCode == QLatin1String{"5"} || nativeErrorCode == QLatin1String{"6"}) { if (retryCount < _maxRetryCount) return safeExec(query, retryCount + 1); } -- 2.20.1