Skip to content

Conversation

@CarlSchwan
Copy link
Member

Use QLatin1String overload when possible (mostly QJsonObject and string comparaison).

See https://www.volkerkrause.eu/2023/09/09/qt-string-bloat.html

Save around 11Kib in the final binary.

queryArgs.addQueryItem(QLatin1String("service"), QLatin1String("files"));
queryArgs.addQueryItem(QLatin1String("t"), data.value("token").toString());
url = QUrl(Utility::concatUrlPath(_account->url(), QLatin1String("public.php"), queryArgs).toString());
queryArgs.addQueryItem(u"service"_s, u"files"_s);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering why these strings don't use the _L1 literal here... does addQueryItem just not accept QLatin1StringViews?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's worth to use a QLatinStringView when the method takes a QAnyStringView (atm it's mostly lot of json, xml relared functions and string comparison)

In the other case, the QLatin1String will be converted first to a QString and in these cases a QStringLiteral is faster

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I see! thanks for the explanation :)

Use QLatin1String overload when possible (mostly QJsonObject and string
comparaison).

See https://www.volkerkrause.eu/2023/09/09/qt-string-bloat.html

Save around 11Kib in the final binary.

Signed-off-by: Carl Schwan <[email protected]>
@mgallien mgallien enabled auto-merge November 3, 2025 12:33
@mgallien mgallien force-pushed the carl/correct-string-overload branch from 1f6c22c to c740c34 Compare November 3, 2025 12:33
@github-actions
Copy link

github-actions bot commented Nov 3, 2025

Artifact containing the AppImage: nextcloud-appimage-pr-8992.zip

Digest: sha256:bb2ce13c6e631bf93fe06bb07981ff67ee7dcf697b56abc110f42c1eb879280a

To test this change/fix you can download the above artifact file, unzip it, and run it.

Please make sure to quit your existing Nextcloud app and backup your data.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 3, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
24 Security Hotspots
59.4% Coverage on New Code (required ≥ 80%)
C Maintainability Rating on New Code (required ≥ A)
1 New Bugs (required ≤ 0)
E Reliability Rating on New Code (required ≥ A)
157 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@mgallien mgallien merged commit b894133 into master Nov 3, 2025
21 of 22 checks passed
@mgallien mgallien deleted the carl/correct-string-overload branch November 3, 2025 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants