diff options
author | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2022-01-18 08:54:52 +0100 |
---|---|---|
committer | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2022-01-18 08:55:23 +0100 |
commit | bd280a087ecab30f94f7937513ee298c233fcba1 (patch) | |
tree | 1209c5adc664e81e664b6be95f45dad86facdcf0 /lib | |
parent | bc4a0f5d408d901f3c8f4dfeec0574ded04845bf (diff) | |
download | libquotient-bd280a087ecab30f94f7937513ee298c233fcba1.tar.gz libquotient-bd280a087ecab30f94f7937513ee298c233fcba1.zip |
Revise inline keyword usage
- Templates and constexpr imply inline
- A function called from a single site better be inlined.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/events/event.h | 2 | ||||
-rw-r--r-- | lib/jobs/basejob.h | 2 | ||||
-rw-r--r-- | lib/quotient_common.h | 8 | ||||
-rw-r--r-- | lib/uri.cpp | 2 | ||||
-rw-r--r-- | lib/util.h | 8 |
5 files changed, 10 insertions, 12 deletions
diff --git a/lib/events/event.h b/lib/events/event.h index 858972da..f10f6a8d 100644 --- a/lib/events/event.h +++ b/lib/events/event.h @@ -311,7 +311,7 @@ inline auto switchOnType(const BaseEventT& event, FnT&& fn) namespace _impl { // Using bool instead of auto below because auto apparently upsets MSVC template <class BaseT, typename FnT> - inline constexpr bool needs_downcast = + constexpr bool needs_downcast = std::is_base_of_v<BaseT, std::decay_t<fn_arg_t<FnT>>> && !std::is_same_v<BaseT, std::decay_t<fn_arg_t<FnT>>>; } diff --git a/lib/jobs/basejob.h b/lib/jobs/basejob.h index 1567e635..9ed58ba8 100644 --- a/lib/jobs/basejob.h +++ b/lib/jobs/basejob.h @@ -28,7 +28,7 @@ class QUOTIENT_API BaseJob : public QObject { static QByteArray encodeIfParam(const QString& paramPart); template <int N> - static inline auto encodeIfParam(const char (&constPart)[N]) + static auto encodeIfParam(const char (&constPart)[N]) { return constPart; } diff --git a/lib/quotient_common.h b/lib/quotient_common.h index 3d38ce1f..af3e2730 100644 --- a/lib/quotient_common.h +++ b/lib/quotient_common.h @@ -77,7 +77,7 @@ enum class Membership : unsigned int { }; QUO_DECLARE_FLAGS_NS(MembershipMask, Membership) -constexpr inline auto MembershipStrings = make_array( +constexpr auto MembershipStrings = make_array( // The order MUST be the same as the order in the original enum "join", "leave", "invite", "knock", "ban"); @@ -95,7 +95,7 @@ enum class JoinState : std::underlying_type_t<Membership> { }; QUO_DECLARE_FLAGS_NS(JoinStates, JoinState) -constexpr inline auto JoinStateStrings = make_array( +constexpr auto JoinStateStrings = make_array( MembershipStrings[0], MembershipStrings[1], MembershipStrings[2], MembershipStrings[3] /* same as MembershipStrings, sans "ban" */ ); @@ -125,9 +125,7 @@ enum RoomType { }; Q_ENUM_NS(RoomType) -constexpr inline auto RoomTypeStrings = make_array( - "m.space" -); +constexpr auto RoomTypeStrings = make_array("m.space"); } // namespace Quotient Q_DECLARE_OPERATORS_FOR_FLAGS(Quotient::MembershipMask) diff --git a/lib/uri.cpp b/lib/uri.cpp index c8843dda..3ce81a21 100644 --- a/lib/uri.cpp +++ b/lib/uri.cpp @@ -75,7 +75,7 @@ static auto decodeFragmentPart(QStringView part) return QUrl::fromPercentEncoding(part.toLatin1()).toUtf8(); } -static auto matrixToUrlRegexInit() +static inline auto matrixToUrlRegexInit() { // See https://matrix.org/docs/spec/appendices#matrix-to-navigation const QRegularExpression MatrixToUrlRE { @@ -54,9 +54,9 @@ using UnorderedMap = std::unordered_map<KeyT, ValT, HashQ<KeyT>>; namespace _impl { template <typename TT> - constexpr inline auto IsOmittableValue = false; + constexpr auto IsOmittableValue = false; template <typename TT> - constexpr inline auto IsOmittable = IsOmittableValue<std::decay_t<TT>>; + constexpr auto IsOmittable = IsOmittableValue<std::decay_t<TT>>; } constexpr auto none = std::nullopt; @@ -165,7 +165,7 @@ Omittable(T&&) -> Omittable<T>; namespace _impl { template <typename T> - constexpr inline auto IsOmittableValue<Omittable<T>> = true; + constexpr auto IsOmittableValue<Omittable<T>> = true; } template <typename T1, typename T2> @@ -191,7 +191,7 @@ inline auto merge(T1& lhs, const Omittable<T2>& rhs) return true; } -inline constexpr auto operator"" _ls(const char* s, std::size_t size) +constexpr auto operator"" _ls(const char* s, std::size_t size) { return QLatin1String(s, int(size)); } |