Skip to content

Commit

Permalink
Everywhere: Remove redundant inline keyword with constexpr
Browse files Browse the repository at this point in the history
Problem:
- `constexpr` functions are additionally decorated with `inline`
  keyword. This is redundant since `constexpr` implies `inline`.

Solution:
- Remove redundancies.
  • Loading branch information
ldm5180 authored and linusg committed Apr 21, 2021
1 parent 42bfaef commit ece8aea
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 65 deletions.
116 changes: 58 additions & 58 deletions AK/EnumBits.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,62 +40,62 @@
#define AK_ENUM_BITWISE_FRIEND_OPERATORS(Enum) \
_AK_ENUM_BITWISE_OPERATORS_INTERNAL(Enum, friend)

#define _AK_ENUM_BITWISE_OPERATORS_INTERNAL(Enum, Prefix) \
\
[[nodiscard]] Prefix constexpr inline Enum operator|(Enum lhs, Enum rhs) \
{ \
using Type = UnderlyingType<Enum>; \
return static_cast<Enum>( \
static_cast<Type>(lhs) | static_cast<Type>(rhs)); \
} \
\
[[nodiscard]] Prefix constexpr inline Enum operator&(Enum lhs, Enum rhs) \
{ \
using Type = UnderlyingType<Enum>; \
return static_cast<Enum>( \
static_cast<Type>(lhs) & static_cast<Type>(rhs)); \
} \
\
[[nodiscard]] Prefix constexpr inline Enum operator^(Enum lhs, Enum rhs) \
{ \
using Type = UnderlyingType<Enum>; \
return static_cast<Enum>( \
static_cast<Type>(lhs) ^ static_cast<Type>(rhs)); \
} \
\
[[nodiscard]] Prefix constexpr inline Enum operator~(Enum rhs) \
{ \
using Type = UnderlyingType<Enum>; \
return static_cast<Enum>( \
~static_cast<Type>(rhs)); \
} \
\
Prefix constexpr inline Enum& operator|=(Enum& lhs, Enum rhs) \
{ \
using Type = UnderlyingType<Enum>; \
lhs = static_cast<Enum>( \
static_cast<Type>(lhs) | static_cast<Type>(rhs)); \
return lhs; \
} \
\
Prefix constexpr inline Enum& operator&=(Enum& lhs, Enum rhs) \
{ \
using Type = UnderlyingType<Enum>; \
lhs = static_cast<Enum>( \
static_cast<Type>(lhs) & static_cast<Type>(rhs)); \
return lhs; \
} \
\
Prefix constexpr inline Enum& operator^=(Enum& lhs, Enum rhs) \
{ \
using Type = UnderlyingType<Enum>; \
lhs = static_cast<Enum>( \
static_cast<Type>(lhs) ^ static_cast<Type>(rhs)); \
return lhs; \
} \
\
Prefix constexpr inline bool has_flag(Enum value, Enum mask) \
{ \
using Type = UnderlyingType<Enum>; \
return static_cast<Type>(value & mask) != 0; \
#define _AK_ENUM_BITWISE_OPERATORS_INTERNAL(Enum, Prefix) \
\
[[nodiscard]] Prefix constexpr Enum operator|(Enum lhs, Enum rhs) \
{ \
using Type = UnderlyingType<Enum>; \
return static_cast<Enum>( \
static_cast<Type>(lhs) | static_cast<Type>(rhs)); \
} \
\
[[nodiscard]] Prefix constexpr Enum operator&(Enum lhs, Enum rhs) \
{ \
using Type = UnderlyingType<Enum>; \
return static_cast<Enum>( \
static_cast<Type>(lhs) & static_cast<Type>(rhs)); \
} \
\
[[nodiscard]] Prefix constexpr Enum operator^(Enum lhs, Enum rhs) \
{ \
using Type = UnderlyingType<Enum>; \
return static_cast<Enum>( \
static_cast<Type>(lhs) ^ static_cast<Type>(rhs)); \
} \
\
[[nodiscard]] Prefix constexpr Enum operator~(Enum rhs) \
{ \
using Type = UnderlyingType<Enum>; \
return static_cast<Enum>( \
~static_cast<Type>(rhs)); \
} \
\
Prefix constexpr Enum& operator|=(Enum& lhs, Enum rhs) \
{ \
using Type = UnderlyingType<Enum>; \
lhs = static_cast<Enum>( \
static_cast<Type>(lhs) | static_cast<Type>(rhs)); \
return lhs; \
} \
\
Prefix constexpr Enum& operator&=(Enum& lhs, Enum rhs) \
{ \
using Type = UnderlyingType<Enum>; \
lhs = static_cast<Enum>( \
static_cast<Type>(lhs) & static_cast<Type>(rhs)); \
return lhs; \
} \
\
Prefix constexpr Enum& operator^=(Enum& lhs, Enum rhs) \
{ \
using Type = UnderlyingType<Enum>; \
lhs = static_cast<Enum>( \
static_cast<Type>(lhs) ^ static_cast<Type>(rhs)); \
return lhs; \
} \
\
Prefix constexpr bool has_flag(Enum value, Enum mask) \
{ \
using Type = UnderlyingType<Enum>; \
return static_cast<Type>(value & mask) != 0; \
}
4 changes: 2 additions & 2 deletions AK/Format.h
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,10 @@ void dmesgln(CheckedFormatString<Parameters...>&& fmt, const Parameters&... para
#endif

template<typename T, typename = void>
inline constexpr bool HasFormatter = true;
constexpr bool HasFormatter = true;

template<typename T>
inline constexpr bool HasFormatter<T, typename Formatter<T>::__no_formatter_defined> = false;
constexpr bool HasFormatter<T, typename Formatter<T>::__no_formatter_defined> = false;

template<typename T>
class FormatIfSupported {
Expand Down
2 changes: 1 addition & 1 deletion Userland/Applications/Spreadsheet/Readers/XSV.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ enum class ReadError {
#undef E
};

inline constexpr ParserBehaviour default_behaviours()
constexpr ParserBehaviour default_behaviours()
{
return ParserBehaviour::QuoteOnlyInFieldStart;
}
Expand Down
2 changes: 1 addition & 1 deletion Userland/Applications/Spreadsheet/Writers/XSV.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ enum class WriteError {
#undef E
};

inline constexpr WriterBehaviour default_behaviours()
constexpr WriterBehaviour default_behaviours()
{
return WriterBehaviour::None;
}
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibCrypto/Hash/SHA1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
namespace Crypto {
namespace Hash {

inline static constexpr auto ROTATE_LEFT(u32 value, size_t bits)
static constexpr auto ROTATE_LEFT(u32 value, size_t bits)
{
return (value << bits) | (value >> (32 - bits));
}
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibGfx/Color.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ class Color {
RGBA32 m_value { 0 };
};

inline constexpr Color::Color(NamedColor named)
constexpr Color::Color(NamedColor named)
{
if (named == Transparent) {
m_value = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
namespace Gfx {

template<size_t N, typename T>
inline static constexpr void normalize(Matrix<N, T>& matrix)
static constexpr void normalize(Matrix<N, T>& matrix)
{
auto sum = 0.0f;
for (size_t i = 0; i < matrix.Size; ++i) {
Expand Down

0 comments on commit ece8aea

Please sign in to comment.