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 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/activitypub') 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))); -- cgit v1.2.3-54-g00ecf