Codechange: add annotation to selectively force inlining in debug build

This commit is contained in:
Rubidium
2023-01-24 22:50:53 +01:00
committed by rubidium42
parent df89c34e03
commit b7a5d8e296
10 changed files with 102 additions and 37 deletions

View File

@@ -29,7 +29,7 @@
* @return The selected bits, aligned to a LSB.
*/
template <typename T>
static inline uint GB(const T x, const uint8 s, const uint8 n)
debug_inline static uint GB(const T x, const uint8 s, const uint8 n)
{
return (x >> s) & (((T)1U << n) - 1);
}
@@ -100,7 +100,7 @@ static inline T AB(T &x, const uint8 s, const uint8 n, const U i)
* @return True if the bit is set, false else.
*/
template <typename T>
static inline bool HasBit(const T x, const uint8 y)
debug_inline static bool HasBit(const T x, const uint8 y)
{
return (x & ((T)1U << y)) != 0;
}

View File

@@ -29,15 +29,15 @@ struct StrongTypedef : StrongTypedefBase {
T value{}; ///< Backing storage field.
constexpr StrongTypedef() = default;
constexpr StrongTypedef(const StrongTypedef &o) = default;
constexpr StrongTypedef(StrongTypedef &&o) = default;
debug_inline constexpr StrongTypedef() = default;
debug_inline constexpr StrongTypedef(const StrongTypedef &o) = default;
debug_inline constexpr StrongTypedef(StrongTypedef &&o) = default;
constexpr StrongTypedef(const T &value) : value(value) {}
debug_inline constexpr StrongTypedef(const T &value) : value(value) {}
constexpr Tthis &operator =(const StrongTypedef &rhs) { this->value = rhs.value; return static_cast<Tthis &>(*this); }
constexpr Tthis &operator =(StrongTypedef &&rhs) { this->value = std::move(rhs.value); return static_cast<Tthis &>(*this); }
constexpr Tthis &operator =(const T &rhs) { this->value = rhs; return static_cast<Tthis &>(*this); }
debug_inline constexpr Tthis &operator =(const StrongTypedef &rhs) { this->value = rhs.value; return static_cast<Tthis &>(*this); }
debug_inline constexpr Tthis &operator =(StrongTypedef &&rhs) { this->value = std::move(rhs.value); return static_cast<Tthis &>(*this); }
debug_inline constexpr Tthis &operator =(const T &rhs) { this->value = rhs; return static_cast<Tthis &>(*this); }
explicit constexpr operator T() const { return this->value; }
@@ -56,6 +56,16 @@ template <class T, class Tthis>
struct StrongIntegralTypedef : StrongTypedef<T, Tthis> {
using StrongTypedef<T, Tthis>::StrongTypedef;
debug_inline constexpr StrongIntegralTypedef() = default;
debug_inline constexpr StrongIntegralTypedef(const StrongIntegralTypedef &o) = default;
debug_inline constexpr StrongIntegralTypedef(StrongIntegralTypedef &&o) = default;
debug_inline constexpr StrongIntegralTypedef(const T &value) : StrongTypedef<T, Tthis>(value) {}
debug_inline constexpr Tthis &operator =(const StrongIntegralTypedef &rhs) { this->value = rhs.value; return static_cast<Tthis &>(*this); }
debug_inline constexpr Tthis &operator =(StrongIntegralTypedef &&rhs) { this->value = std::move(rhs.value); return static_cast<Tthis &>(*this); }
debug_inline constexpr Tthis &operator =(const T &rhs) { this->value = rhs; return static_cast<Tthis &>(*this); }
constexpr Tthis &operator ++() { this->value++; return static_cast<Tthis &>(*this); }
constexpr Tthis &operator --() { this->value--; return static_cast<Tthis &>(*this); }
constexpr Tthis operator ++(int) { auto res = static_cast<Tthis &>(*this); this->value++; return res; }