Skip to content

Commit 1f184c0

Browse files
committed
refactor: replace QString() with QStringLiteral() for better performance
Signed-off-by: Integral <[email protected]>
1 parent 1ffc210 commit 1f184c0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+144
-144
lines changed

src/cmd/cmd.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ int main(int argc, char **argv)
315315

316316
#ifdef Q_OS_WIN
317317
// Ensure OpenSSL config file is only loaded from app directory
318-
QString opensslConf = QCoreApplication::applicationDirPath() + QString("/openssl.cnf");
318+
QString opensslConf = QCoreApplication::applicationDirPath() + QStringLiteral("/openssl.cnf");
319319
qputenv("OPENSSL_CONF", opensslConf.toLocal8Bit());
320320
#endif
321321

src/gui/application.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ Application::Application(int &argc, char **argv)
222222

223223
#ifdef Q_OS_WIN
224224
// Ensure OpenSSL config file is only loaded from app directory
225-
QString opensslConf = QCoreApplication::applicationDirPath() + QString("/openssl.cnf");
225+
QString opensslConf = QCoreApplication::applicationDirPath() + QStringLiteral("/openssl.cnf");
226226
qputenv("OPENSSL_CONF", opensslConf.toLocal8Bit());
227227
#endif
228228

src/gui/cloudproviders/cloudproviderwrapper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ CloudProviderWrapper::CloudProviderWrapper(QObject *parent, Folder *folder, int
3636
{
3737
GMenuModel *model = nullptr;
3838
GActionGroup *action_group = nullptr;
39-
QString accountName = QString("Folder/%1").arg(folderId);
39+
QString accountName = QStringLiteral("Folder/%1").arg(folderId);
4040

4141
_cloudProvider = CLOUD_PROVIDERS_PROVIDER_EXPORTER(cloudprovider);
4242
_cloudProviderAccount = cloud_providers_account_exporter_new(_cloudProvider, accountName.toUtf8().data());
@@ -170,7 +170,7 @@ void CloudProviderWrapper::slotUpdateProgress(const QString &folder, const Progr
170170

171171
void CloudProviderWrapper::updateStatusText(QString statusText)
172172
{
173-
QString status = QString("%1 - %2").arg(_folder->accountState()->stateString(_folder->accountState()->state()), statusText);
173+
QString status = QStringLiteral("%1 - %2").arg(_folder->accountState()->stateString(_folder->accountState()->state()), statusText);
174174
cloud_providers_account_exporter_set_status_details(_cloudProviderAccount, status.toUtf8().data());
175175
}
176176

src/gui/creds/flow2auth.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ void Flow2Auth::slotPollTimerTimeout()
198198
req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
199199

200200
auto requestBody = new QBuffer;
201-
QUrlQuery arguments(QString("token=%1").arg(_pollToken));
201+
QUrlQuery arguments(QStringLiteral("token=%1").arg(_pollToken));
202202
requestBody->setData(arguments.query(QUrl::FullyEncoded).toLatin1());
203203

204204
auto job = _account->sendRequest("POST", _pollEndpoint, req, requestBody);

src/gui/filedetails/sharemodel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ QString ShareModel::avatarUrlForShare(const SharePtr &share) const
788788
const auto provider = QStringLiteral("image://tray-image-provider/");
789789
const auto userId = share->getShareWith()->shareWith();
790790
const auto avatarUrl = Utility::concatUrlPath(_accountState->account()->url(),
791-
QString("remote.php/dav/avatars/%1/%2.png").arg(userId, QString::number(64))).toString();
791+
QStringLiteral("remote.php/dav/avatars/%1/%2.png").arg(userId, QString::number(64))).toString();
792792
return QString(provider + avatarUrl);
793793
}
794794

@@ -1464,7 +1464,7 @@ QString ShareModel::generatePassword()
14641464
static const QRegularExpression lowercaseMatch("[a-z]");
14651465
static const QRegularExpression uppercaseMatch("[A-Z]");
14661466
static const QRegularExpression numberMatch("[0-9]");
1467-
static const QRegularExpression specialCharMatch(QString("[%1]").arg(specialChars.data()));
1467+
static const QRegularExpression specialCharMatch(QStringLiteral("[%1]").arg(specialChars.data()));
14681468

14691469
static const std::map<std::string_view, QRegularExpression> matchMap{
14701470
{lowercaseAlphabet, lowercaseMatch},

src/gui/foldercreationdialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ FolderCreationDialog::FolderCreationDialog(const QString &destination, QWidget *
4545
ui->newFolderNameEdit->setText(suggestedFolderNamePrefix);
4646
} else {
4747
for (unsigned int i = 2; i < std::numeric_limits<unsigned int>::max(); ++i) {
48-
const QString suggestedPostfix = QString(" (%1)").arg(i);
48+
const QString suggestedPostfix = QStringLiteral(" (%1)").arg(i);
4949

5050
if (!QDir(newFolderFullPath + suggestedPostfix).exists()) {
5151
ui->newFolderNameEdit->setText(suggestedFolderNamePrefix + suggestedPostfix);

src/gui/folderstatusmodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
219219
case Qt::DisplayRole:
220220
if (folderInfo->_hasError) {
221221
return {tr("Error while loading the list of folders from the server.")
222-
+ QString("\n")
222+
+ QStringLiteral("\n")
223223
+ folderInfo->_lastErrorString};
224224
} else {
225225
return tr("Fetching folder list from server …");

src/gui/ocssharejob.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ void OcsShareJob::getShares(const QString &path, const QMap<QString, QString> &p
3333
setVerb("GET");
3434

3535
addParam(QString::fromLatin1("path"), path);
36-
addParam(QString::fromLatin1("reshares"), QString("true"));
37-
addParam(QString::fromLatin1("shared_with_me"), QString("true"));
36+
addParam(QString::fromLatin1("reshares"), QStringLiteral("true"));
37+
addParam(QString::fromLatin1("shared_with_me"), QStringLiteral("true"));
3838

3939
for (auto it = std::cbegin(params); it != std::cend(params); ++it) {
4040
addParam(it.key(), it.value());

src/gui/remotewipe.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void RemoteWipe::startCheckJobWithAppPassword(QString pwd){
5858
request.setUrl(requestUrl);
5959
request.setSslConfiguration(_account->getOrCreateSslConfig());
6060
auto requestBody = new QBuffer;
61-
QUrlQuery arguments(QString("token=%1").arg(_appPassword));
61+
QUrlQuery arguments(QStringLiteral("token=%1").arg(_appPassword));
6262
requestBody->setData(arguments.query(QUrl::FullyEncoded).toLatin1());
6363
_networkReplyCheck = _networkManager.post(request, requestBody);
6464
QObject::connect(&_networkManager, &QNetworkAccessManager::sslErrors,
@@ -79,16 +79,16 @@ void RemoteWipe::checkJobSlot()
7979
jsonParseError.error != QJsonParseError::NoError) {
8080
QString errorFromJson = json["error"].toString();
8181
if (!errorFromJson.isEmpty()) {
82-
qCWarning(lcRemoteWipe) << QString("Error returned from the server: <em>%1<em>")
82+
qCWarning(lcRemoteWipe) << QStringLiteral("Error returned from the server: <em>%1<em>")
8383
.arg(errorFromJson.toHtmlEscaped());
8484
} else if (_networkReplyCheck->error() != QNetworkReply::NoError) {
85-
qCWarning(lcRemoteWipe) << QString("There was an error accessing the 'token' endpoint: <br><em>%1</em>")
85+
qCWarning(lcRemoteWipe) << QStringLiteral("There was an error accessing the 'token' endpoint: <br><em>%1</em>")
8686
.arg(_networkReplyCheck->errorString().toHtmlEscaped());
8787
} else if (jsonParseError.error != QJsonParseError::NoError) {
88-
qCWarning(lcRemoteWipe) << QString("Could not parse the JSON returned from the server: <br><em>%1</em>")
88+
qCWarning(lcRemoteWipe) << QStringLiteral("Could not parse the JSON returned from the server: <br><em>%1</em>")
8989
.arg(jsonParseError.errorString());
9090
} else {
91-
qCWarning(lcRemoteWipe) << QString("The reply from the server did not contain all expected fields");
91+
qCWarning(lcRemoteWipe) << QStringLiteral("The reply from the server did not contain all expected fields");
9292
}
9393

9494
// check for wipe request
@@ -136,7 +136,7 @@ void RemoteWipe::notifyServerSuccessJob(AccountState *accountState, bool dataWip
136136
request.setUrl(requestUrl);
137137
request.setSslConfiguration(_account->getOrCreateSslConfig());
138138
auto requestBody = new QBuffer;
139-
QUrlQuery arguments(QString("token=%1").arg(_appPassword));
139+
QUrlQuery arguments(QStringLiteral("token=%1").arg(_appPassword));
140140
requestBody->setData(arguments.query(QUrl::FullyEncoded).toLatin1());
141141
_networkReplySuccess = _networkManager.post(request, requestBody);
142142
QObject::connect(_networkReplySuccess, &QNetworkReply::finished, this,
@@ -153,16 +153,16 @@ void RemoteWipe::notifyServerSuccessJobSlot()
153153
jsonParseError.error != QJsonParseError::NoError) {
154154
QString errorFromJson = json["error"].toString();
155155
if (!errorFromJson.isEmpty()) {
156-
qCWarning(lcRemoteWipe) << QString("Error returned from the server: <em>%1</em>")
156+
qCWarning(lcRemoteWipe) << QStringLiteral("Error returned from the server: <em>%1</em>")
157157
.arg(errorFromJson.toHtmlEscaped());
158158
} else if (_networkReplySuccess->error() != QNetworkReply::NoError) {
159-
qCWarning(lcRemoteWipe) << QString("There was an error accessing the 'success' endpoint: <br><em>%1</em>")
159+
qCWarning(lcRemoteWipe) << QStringLiteral("There was an error accessing the 'success' endpoint: <br><em>%1</em>")
160160
.arg(_networkReplySuccess->errorString().toHtmlEscaped());
161161
} else if (jsonParseError.error != QJsonParseError::NoError) {
162-
qCWarning(lcRemoteWipe) << QString("Could not parse the JSON returned from the server: <br><em>%1</em>")
162+
qCWarning(lcRemoteWipe) << QStringLiteral("Could not parse the JSON returned from the server: <br><em>%1</em>")
163163
.arg(jsonParseError.errorString());
164164
} else {
165-
qCWarning(lcRemoteWipe) << QString("The reply from the server did not contain all expected fields.");
165+
qCWarning(lcRemoteWipe) << QStringLiteral("The reply from the server did not contain all expected fields.");
166166
}
167167
}
168168

src/gui/socketapi/socketapi.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,13 +1151,13 @@ void SocketApi::command_GET_STRINGS(const QString &argument, SocketListener *lis
11511151
{ "EMAIL_PRIVATE_LINK_MENU_TITLE", tr("Send private link by email …") },
11521152
{ "CONTEXT_MENU_ICON", APPLICATION_ICON_NAME },
11531153
} };
1154-
listener->sendMessage(QString("GET_STRINGS:BEGIN"));
1154+
listener->sendMessage(QStringLiteral("GET_STRINGS:BEGIN"));
11551155
for (const auto& key_value : strings) {
11561156
if (argument.isEmpty() || argument == QLatin1String(key_value.first)) {
1157-
listener->sendMessage(QString("STRING:%1:%2").arg(key_value.first, key_value.second));
1157+
listener->sendMessage(QStringLiteral("STRING:%1:%2").arg(key_value.first, key_value.second));
11581158
}
11591159
}
1160-
listener->sendMessage(QString("GET_STRINGS:END"));
1160+
listener->sendMessage(QStringLiteral("GET_STRINGS:END"));
11611161
}
11621162

11631163
void SocketApi::sendSharingContextMenuOptions(const FileData &fileData, SocketListener *listener, SharingContextItemEncryptedFlag itemEncryptionFlag, SharingContextItemRootEncryptedFolderFlag rootE2eeFolderFlag)
@@ -1325,7 +1325,7 @@ SocketApi::FileData SocketApi::FileData::parentFolder() const
13251325

13261326
void SocketApi::command_GET_MENU_ITEMS(const QString &argument, OCC::SocketListener *listener)
13271327
{
1328-
listener->sendMessage(QString("GET_MENU_ITEMS:BEGIN"), true);
1328+
listener->sendMessage(QStringLiteral("GET_MENU_ITEMS:BEGIN"), true);
13291329
const QStringList files = split(argument);
13301330

13311331
// Find the common sync folder.
@@ -1483,7 +1483,7 @@ void SocketApi::command_GET_MENU_ITEMS(const QString &argument, OCC::SocketListe
14831483
}
14841484
}
14851485

1486-
listener->sendMessage(QString("GET_MENU_ITEMS:END"));
1486+
listener->sendMessage(QStringLiteral("GET_MENU_ITEMS:END"));
14871487
}
14881488

14891489
DirectEditor* SocketApi::getDirectEditorForLocalFile(const QString &localFile)

0 commit comments

Comments
 (0)