From fa9b2130f43547be7e4698b8d95a23155c5d3ee1 Mon Sep 17 00:00:00 2001 From: ConfuSomu Date: Fri, 26 Jan 2024 13:52:47 -0500 Subject: Use QStringLiteral in some places This should provide a light performance improvement as the QString is built at compile time, with the generated data being stored in the read-only segment of the built object file. --- src/activitypub/apactivity.cpp | 2 +- src/activitypub/apattachment.cpp | 4 ++-- src/activitypub/appost.cpp | 2 +- src/activitypub/apquestion.cpp | 4 ++-- src/mainwindow.cpp | 2 +- src/widgets/tab_activity_list.cpp | 2 +- src/widgets/tab_actor_info.cpp | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/activitypub/apactivity.cpp b/src/activitypub/apactivity.cpp index 6717731..b44f87a 100644 --- a/src/activitypub/apactivity.cpp +++ b/src/activitypub/apactivity.cpp @@ -27,7 +27,7 @@ APActivity::~APActivity() { } QString APActivity::get_html_render(HtmlRenderDetails render_info) { - QString html(get_html_template("apactivity")); + QString html(get_html_template(QStringLiteral("apactivity"))); switch (type) { case APActivityType::CREATE: diff --git a/src/activitypub/apattachment.cpp b/src/activitypub/apattachment.cpp index 342ea21..b5c82ce 100644 --- a/src/activitypub/apattachment.cpp +++ b/src/activitypub/apattachment.cpp @@ -11,7 +11,7 @@ APAttachment::APAttachment(APAttachmentFields fields) { } QString APAttachment::get_html_render(HtmlRenderDetails info) { - QString html(get_html_template("apattachment")); + QString html(get_html_template(QStringLiteral("apattachment"))); if (not path_url.isEmpty()) { html.replace("{{path}}", path_url); @@ -59,7 +59,7 @@ QString APAttachmentList::get_html_render(HtmlRenderDetails render_info) { int i = 1; for (APAttachment attachment : *this) { - QString item_html(get_html_template("apattachmentlist_item")); + QString item_html(get_html_template(QStringLiteral("apattachmentlist_item"))); item_html.replace("{{id}}", QString::number(i)); item_html.replace("{{attachment}}", attachment.get_html_render(render_info)); diff --git a/src/activitypub/appost.cpp b/src/activitypub/appost.cpp index 87d6f08..c1f78d4 100644 --- a/src/activitypub/appost.cpp +++ b/src/activitypub/appost.cpp @@ -42,7 +42,7 @@ QString APPost::get_html_status_languages() { } QString APPost::get_html_render(HtmlRenderDetails render_info) { - QString html(get_html_template("appost")); + QString html(get_html_template(QStringLiteral("appost"))); if (published.isValid()) { // Using QLocale::toString() is forward compatible with Qt 6 as QDateTime::toString() will not return anymore a string in the system locale. diff --git a/src/activitypub/apquestion.cpp b/src/activitypub/apquestion.cpp index 9cdffd0..3796174 100644 --- a/src/activitypub/apquestion.cpp +++ b/src/activitypub/apquestion.cpp @@ -16,7 +16,7 @@ APQuestion::APQuestion(APObjectFields fields) : APPost(fields) { QString APQuestion::get_html_render(HtmlRenderDetails render_info) { QString html(APPost::get_html_render(render_info)); - html.append(get_html_template("appoll")); + html.append(get_html_template(QStringLiteral("appoll"))); if (end_time.isValid()) { html.replace("{{end-time}}", render_info.locale->toString( @@ -39,7 +39,7 @@ QString APQuestion::get_html_poll_options(HtmlRenderDetails render_info) { QString full; for (PollOption option : options) { - QString html(get_html_template("appoll_item")); + QString html(get_html_template(QStringLiteral("appoll_item"))); html.replace("{{name}}", option.name); html.replace("{{votes}}", render_info.locale->toString(option.votes)); html.replace("{{votes-percent}}", render_info.locale->toString((int)((float)option.votes/(float)total_votes * 100))); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 16686c4..7789cf4 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -70,7 +70,7 @@ void MainWindow::act_command_line(CommandLineParsedOptions &options, QCommandLin QMessageBox::critical(this, tr("Command line"), tr("The passed command line is incorrect and will be ignored.\nMore information: %1").arg(options.error_message)); exit(EXIT_FAILURE); break; case CommandLineHelpRequested: - QMessageBox::information(this, QGuiApplication::applicationDisplayName(), "
" + parser.helpText() + "
"); exit(EXIT_SUCCESS); + QMessageBox::information(this, QGuiApplication::applicationDisplayName(), QStringLiteral("
%1
").arg(parser.helpText())); exit(EXIT_SUCCESS); break; case CommandLineVersionRequested: on_actionAbout_triggered(true); exit(EXIT_SUCCESS); diff --git a/src/widgets/tab_activity_list.cpp b/src/widgets/tab_activity_list.cpp index dd40de7..bd396c5 100644 --- a/src/widgets/tab_activity_list.cpp +++ b/src/widgets/tab_activity_list.cpp @@ -85,7 +85,7 @@ void TabActivityList::set_search_text(const QString &text) { void TabActivityList::actionOpen_URL_triggered(bool checked) { bool ok; - QString url = QInputDialog::getText(this, tr("Open status from URL"), tr("Status URL:"), QLineEdit::Normal, "https://…", &ok); + QString url = QInputDialog::getText(this, tr("Open status from URL"), tr("Status URL:"), QLineEdit::Normal, QStringLiteral("https://…"), &ok); // TODO: Move all of this to another thread // TODO: Reuse the Instance object diff --git a/src/widgets/tab_actor_info.cpp b/src/widgets/tab_actor_info.cpp index f991366..9d35b29 100644 --- a/src/widgets/tab_actor_info.cpp +++ b/src/widgets/tab_actor_info.cpp @@ -32,7 +32,7 @@ TabActorInfo::~TabActorInfo() { // TODO: do this in another thread, like for status_info void TabActorInfo::update_ui() { if (not actor) { - ui->displayNameText->setText(QString("

%1

").arg(tr("Failed to display Actor"))); + ui->displayNameText->setText(QStringLiteral("

%1

").arg(tr("Failed to display Actor"))); ui->avatarImage->setText(""); return; } -- cgit v1.2.3-54-g00ecf