From c7907084282c7957d085acb329574ab6a7d593c8 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Tue, 18 Jan 2022 11:43:32 +0100 Subject: Move over non-interface code to QLatin1String It's better than const char* because any interaction between const char* and QString assumes that const char* contains UTF-8, which is pessimistic and therefore inefficient; at the same time: - construction of QString from QLatin1String is extremely fast (boiling down to padding null bytes) - "something"_ls is much shorter than QStringLiteral("something") - "something"_ls produces a direct pointer to the literal at compile time, using the benefits of raw string literals (deduplication, e.g.) The library API will also transition to QLatin1String where applicable, likely in 0.8. --- lib/settings.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/settings.cpp') diff --git a/lib/settings.cpp b/lib/settings.cpp index 5549e4de..20734a7e 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -3,6 +3,7 @@ #include "settings.h" +#include "util.h" #include "logging.h" #include @@ -109,10 +110,10 @@ QUO_DEFINE_SETTING(AccountSettings, QString, deviceName, "device_name", {}, QUO_DEFINE_SETTING(AccountSettings, bool, keepLoggedIn, "keep_logged_in", false, setKeepLoggedIn) -static const auto HomeserverKey = QStringLiteral("homeserver"); -static const auto AccessTokenKey = QStringLiteral("access_token"); -static const auto EncryptionAccountPickleKey = - QStringLiteral("encryption_account_pickle"); +static constexpr auto HomeserverKey = "homeserver"_ls; +static constexpr auto AccessTokenKey = "access_token"_ls; +static constexpr auto EncryptionAccountPickleKey = + "encryption_account_pickle"_ls; QUrl AccountSettings::homeserver() const { -- cgit v1.2.3