aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-01-18 11:43:21 +0100
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-01-18 11:43:55 +0100
commitbf82aeea369cacfc93a0e6d6d9feb01f1f2afdb2 (patch)
treef38cd3f38465a0cf8b38c198b202e624fe939ae1
parentc7907084282c7957d085acb329574ab6a7d593c8 (diff)
downloadlibquotient-bf82aeea369cacfc93a0e6d6d9feb01f1f2afdb2.tar.gz
libquotient-bf82aeea369cacfc93a0e6d6d9feb01f1f2afdb2.zip
Don't use 'static' on top-level/namespace scope
When internal linkage is necessary, anonymous namespaces fulfil the same purpose in a better way. See also: https://stackoverflow.com/questions/4422507/superiority-of-unnamed-namespace-over-static
-rw-r--r--lib/converters.h2
-rw-r--r--lib/events/roommessageevent.cpp18
-rw-r--r--lib/settings.cpp9
-rw-r--r--lib/uri.cpp6
4 files changed, 22 insertions, 13 deletions
diff --git a/lib/converters.h b/lib/converters.h
index a6028f1b..8eea1cd3 100644
--- a/lib/converters.h
+++ b/lib/converters.h
@@ -355,7 +355,7 @@ namespace _impl {
};
} // namespace _impl
-static constexpr bool IfNotEmpty = false;
+constexpr bool IfNotEmpty = false;
/*! Add a key-value pair to QJsonObject or QUrlQuery
*
diff --git a/lib/events/roommessageevent.cpp b/lib/events/roommessageevent.cpp
index 0f58d8a6..5ab0f845 100644
--- a/lib/events/roommessageevent.cpp
+++ b/lib/events/roommessageevent.cpp
@@ -19,13 +19,15 @@ using namespace EventContent;
using MsgType = RoomMessageEvent::MsgType;
-static constexpr auto RelatesToKey = "m.relates_to"_ls;
-static constexpr auto MsgTypeKey = "msgtype"_ls;
-static constexpr auto FormattedBodyKey = "formatted_body"_ls;
-static constexpr auto TextTypeKey = "m.text"_ls;
-static constexpr auto EmoteTypeKey = "m.emote"_ls;
-static constexpr auto NoticeTypeKey = "m.notice"_ls;
-static constexpr auto HtmlContentTypeId = "org.matrix.custom.html"_ls;
+namespace { // Supporting internal definitions
+
+constexpr auto RelatesToKey = "m.relates_to"_ls;
+constexpr auto MsgTypeKey = "msgtype"_ls;
+constexpr auto FormattedBodyKey = "formatted_body"_ls;
+constexpr auto TextTypeKey = "m.text"_ls;
+constexpr auto EmoteTypeKey = "m.emote"_ls;
+constexpr auto NoticeTypeKey = "m.notice"_ls;
+constexpr auto HtmlContentTypeId = "org.matrix.custom.html"_ls;
template <typename ContentT>
TypedBase* make(const QJsonObject& json)
@@ -87,6 +89,8 @@ inline bool isReplacement(const Omittable<RelatesTo>& rel)
return rel && rel->type == RelatesTo::ReplacementTypeId();
}
+} // anonymous namespace
+
QJsonObject RoomMessageEvent::assembleContentJson(const QString& plainBody,
const QString& jsonMsgType,
TypedBase* content)
diff --git a/lib/settings.cpp b/lib/settings.cpp
index 20734a7e..2491d89d 100644
--- a/lib/settings.cpp
+++ b/lib/settings.cpp
@@ -110,10 +110,11 @@ QUO_DEFINE_SETTING(AccountSettings, QString, deviceName, "device_name", {},
QUO_DEFINE_SETTING(AccountSettings, bool, keepLoggedIn, "keep_logged_in", false,
setKeepLoggedIn)
-static constexpr auto HomeserverKey = "homeserver"_ls;
-static constexpr auto AccessTokenKey = "access_token"_ls;
-static constexpr auto EncryptionAccountPickleKey =
- "encryption_account_pickle"_ls;
+namespace {
+constexpr auto HomeserverKey = "homeserver"_ls;
+constexpr auto AccessTokenKey = "access_token"_ls;
+constexpr auto EncryptionAccountPickleKey = "encryption_account_pickle"_ls;
+}
QUrl AccountSettings::homeserver() const
{
diff --git a/lib/uri.cpp b/lib/uri.cpp
index 11c59b69..6b7d1d20 100644
--- a/lib/uri.cpp
+++ b/lib/uri.cpp
@@ -10,12 +10,14 @@
using namespace Quotient;
+namespace {
+
struct ReplacePair { QLatin1String uriString; char sigil; };
/// \brief Defines bi-directional mapping of path prefixes and sigils
///
/// When there are two prefixes for the same sigil, the first matching
/// entry for a given sigil is used.
-static const ReplacePair replacePairs[] = {
+const ReplacePair replacePairs[] = {
{ "u/"_ls, '@' },
{ "user/"_ls, '@' },
{ "roomid/"_ls, '!' },
@@ -27,6 +29,8 @@ static const ReplacePair replacePairs[] = {
{ "event/"_ls, '$' }
};
+}
+
Uri::Uri(QByteArray primaryId, QByteArray secondaryId, QString query)
{
if (primaryId.isEmpty())