Codechange: replace static inline with static for non-class functions
This commit is contained in:
@@ -26,7 +26,7 @@ void NORETURN ReallocError(size_t size);
|
||||
* @param element_size Size of the structure to allocate.
|
||||
* @param num_elements Number of elements to allocate.
|
||||
*/
|
||||
static inline void CheckAllocationConstraints(size_t element_size, size_t num_elements)
|
||||
inline void CheckAllocationConstraints(size_t element_size, size_t num_elements)
|
||||
{
|
||||
if (num_elements > SIZE_MAX / element_size) MallocError(SIZE_MAX);
|
||||
}
|
||||
@@ -38,7 +38,7 @@ static inline void CheckAllocationConstraints(size_t element_size, size_t num_el
|
||||
* @param num_elements Number of elements to allocate.
|
||||
*/
|
||||
template <typename T>
|
||||
static inline void CheckAllocationConstraints(size_t num_elements)
|
||||
inline void CheckAllocationConstraints(size_t num_elements)
|
||||
{
|
||||
CheckAllocationConstraints(sizeof(T), num_elements);
|
||||
}
|
||||
@@ -54,7 +54,7 @@ static inline void CheckAllocationConstraints(size_t num_elements)
|
||||
* @return nullptr when num_elements == 0, non-nullptr otherwise.
|
||||
*/
|
||||
template <typename T>
|
||||
static inline T *MallocT(size_t num_elements)
|
||||
inline T *MallocT(size_t num_elements)
|
||||
{
|
||||
/*
|
||||
* MorphOS cannot handle 0 elements allocations, or rather that always
|
||||
@@ -82,7 +82,7 @@ static inline T *MallocT(size_t num_elements)
|
||||
* @return nullptr when num_elements == 0, non-nullptr otherwise.
|
||||
*/
|
||||
template <typename T>
|
||||
static inline T *CallocT(size_t num_elements)
|
||||
inline T *CallocT(size_t num_elements)
|
||||
{
|
||||
/*
|
||||
* MorphOS cannot handle 0 elements allocations, or rather that always
|
||||
@@ -108,7 +108,7 @@ static inline T *CallocT(size_t num_elements)
|
||||
* @return nullptr when num_elements == 0, non-nullptr otherwise.
|
||||
*/
|
||||
template <typename T>
|
||||
static inline T *ReallocT(T *t_ptr, size_t num_elements)
|
||||
inline T *ReallocT(T *t_ptr, size_t num_elements)
|
||||
{
|
||||
/*
|
||||
* MorphOS cannot handle 0 elements allocations, or rather that always
|
||||
|
@@ -55,7 +55,7 @@ debug_inline constexpr static uint GB(const T x, const uint8_t s, const uint8_t
|
||||
* @return The new value of \a x
|
||||
*/
|
||||
template <typename T, typename U>
|
||||
static inline T SB(T &x, const uint8_t s, const uint8_t n, const U d)
|
||||
inline T SB(T &x, const uint8_t s, const uint8_t n, const U d)
|
||||
{
|
||||
x &= (T)(~((((T)1U << n) - 1) << s));
|
||||
x |= (T)(d << s);
|
||||
@@ -80,7 +80,7 @@ static inline T SB(T &x, const uint8_t s, const uint8_t n, const U d)
|
||||
* @return The new value of \a x
|
||||
*/
|
||||
template <typename T, typename U>
|
||||
static inline T AB(T &x, const uint8_t s, const uint8_t n, const U i)
|
||||
inline T AB(T &x, const uint8_t s, const uint8_t n, const U i)
|
||||
{
|
||||
const T mask = ((((T)1U << n) - 1) << s);
|
||||
x = (T)((x & ~mask) | ((x + (i << s)) & mask));
|
||||
@@ -118,7 +118,7 @@ debug_inline static bool HasBit(const T x, const uint8_t y)
|
||||
* @return The new value of the old value with the bit set
|
||||
*/
|
||||
template <typename T>
|
||||
static inline T SetBit(T &x, const uint8_t y)
|
||||
inline T SetBit(T &x, const uint8_t y)
|
||||
{
|
||||
return x = (T)(x | ((T)1U << y));
|
||||
}
|
||||
@@ -148,7 +148,7 @@ static inline T SetBit(T &x, const uint8_t y)
|
||||
* @return The new value of the old value with the bit cleared
|
||||
*/
|
||||
template <typename T>
|
||||
static inline T ClrBit(T &x, const uint8_t y)
|
||||
inline T ClrBit(T &x, const uint8_t y)
|
||||
{
|
||||
return x = (T)(x & ~((T)1U << y));
|
||||
}
|
||||
@@ -178,7 +178,7 @@ static inline T ClrBit(T &x, const uint8_t y)
|
||||
* @return The new value of the old value with the bit toggled
|
||||
*/
|
||||
template <typename T>
|
||||
static inline T ToggleBit(T &x, const uint8_t y)
|
||||
inline T ToggleBit(T &x, const uint8_t y)
|
||||
{
|
||||
return x = (T)(x ^ ((T)1U << y));
|
||||
}
|
||||
@@ -213,7 +213,7 @@ extern const uint8_t _ffb_64[64];
|
||||
* @return The position of the first bit which is set
|
||||
* @see FIND_FIRST_BIT
|
||||
*/
|
||||
static inline uint8_t FindFirstBit2x64(const int value)
|
||||
inline uint8_t FindFirstBit2x64(const int value)
|
||||
{
|
||||
if ((value & 0xFF) == 0) {
|
||||
return FIND_FIRST_BIT((value >> 8) & 0x3F) + 8;
|
||||
@@ -236,7 +236,7 @@ uint8_t FindLastBit(uint64_t x);
|
||||
* @return The new value with the first bit cleared
|
||||
*/
|
||||
template <typename T>
|
||||
static inline T KillFirstBit(T value)
|
||||
inline T KillFirstBit(T value)
|
||||
{
|
||||
return value &= (T)(value - 1);
|
||||
}
|
||||
@@ -248,7 +248,7 @@ static inline T KillFirstBit(T value)
|
||||
* @return the number of bits.
|
||||
*/
|
||||
template <typename T>
|
||||
static inline uint CountBits(T value)
|
||||
inline uint CountBits(T value)
|
||||
{
|
||||
uint num;
|
||||
|
||||
@@ -271,7 +271,7 @@ static inline uint CountBits(T value)
|
||||
* @return does \a value have exactly 1 bit set?
|
||||
*/
|
||||
template <typename T>
|
||||
static inline bool HasExactlyOneBit(T value)
|
||||
inline bool HasExactlyOneBit(T value)
|
||||
{
|
||||
return value != 0 && (value & (value - 1)) == 0;
|
||||
}
|
||||
@@ -283,7 +283,7 @@ static inline bool HasExactlyOneBit(T value)
|
||||
* @return does \a value have at most 1 bit set?
|
||||
*/
|
||||
template <typename T>
|
||||
static inline bool HasAtMostOneBit(T value)
|
||||
inline bool HasAtMostOneBit(T value)
|
||||
{
|
||||
return (value & (value - 1)) == 0;
|
||||
}
|
||||
@@ -298,7 +298,7 @@ static inline bool HasAtMostOneBit(T value)
|
||||
* @return A bit rotated number
|
||||
*/
|
||||
template <typename T>
|
||||
static inline T ROL(const T x, const uint8_t n)
|
||||
inline T ROL(const T x, const uint8_t n)
|
||||
{
|
||||
if (n == 0) return x;
|
||||
return (T)(x << n | x >> (sizeof(x) * 8 - n));
|
||||
@@ -314,7 +314,7 @@ static inline T ROL(const T x, const uint8_t n)
|
||||
* @return A bit rotated number
|
||||
*/
|
||||
template <typename T>
|
||||
static inline T ROR(const T x, const uint8_t n)
|
||||
inline T ROR(const T x, const uint8_t n)
|
||||
{
|
||||
if (n == 0) return x;
|
||||
return (T)(x >> n | x << (sizeof(x) * 8 - n));
|
||||
|
@@ -38,12 +38,12 @@
|
||||
# define TO_LE32X(x) (x)
|
||||
#endif /* TTD_ENDIAN == TTD_BIG_ENDIAN */
|
||||
|
||||
static inline uint16_t ReadLE16Aligned(const void *x)
|
||||
inline uint16_t ReadLE16Aligned(const void *x)
|
||||
{
|
||||
return FROM_LE16(*(const uint16_t*)x);
|
||||
}
|
||||
|
||||
static inline uint16_t ReadLE16Unaligned(const void *x)
|
||||
inline uint16_t ReadLE16Unaligned(const void *x)
|
||||
{
|
||||
#if OTTD_ALIGNMENT == 1
|
||||
return ((const byte*)x)[0] | ((const byte*)x)[1] << 8;
|
||||
|
@@ -19,7 +19,7 @@ Dimension maxdim(const Dimension &d1, const Dimension &d2);
|
||||
* @param r Rectangle to check.
|
||||
* @return True if and only if the rectangle doesn't define space.
|
||||
*/
|
||||
static inline bool IsEmptyRect(const Rect &r)
|
||||
inline bool IsEmptyRect(const Rect &r)
|
||||
{
|
||||
return (r.left | r.top | r.right | r.bottom) == 0;
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@
|
||||
* @return The unsigned value
|
||||
*/
|
||||
template <typename T>
|
||||
static inline T abs(const T a)
|
||||
inline T abs(const T a)
|
||||
{
|
||||
return (a < (T)0) ? -a : a;
|
||||
}
|
||||
@@ -34,7 +34,7 @@ static inline T abs(const T a)
|
||||
* @return The smallest multiple of n equal or greater than x
|
||||
*/
|
||||
template <typename T>
|
||||
static inline T Align(const T x, uint n)
|
||||
inline T Align(const T x, uint n)
|
||||
{
|
||||
assert((n & (n - 1)) == 0 && n != 0);
|
||||
n--;
|
||||
@@ -52,7 +52,7 @@ static inline T Align(const T x, uint n)
|
||||
* @see Align()
|
||||
*/
|
||||
template <typename T>
|
||||
static inline T *AlignPtr(T *x, uint n)
|
||||
inline T *AlignPtr(T *x, uint n)
|
||||
{
|
||||
static_assert(sizeof(size_t) == sizeof(void *));
|
||||
return reinterpret_cast<T *>(Align((size_t)x, n));
|
||||
@@ -76,7 +76,7 @@ static inline T *AlignPtr(T *x, uint n)
|
||||
* @see Clamp(int, int, int)
|
||||
*/
|
||||
template <typename T>
|
||||
static inline T Clamp(const T a, const T min, const T max)
|
||||
inline T Clamp(const T a, const T min, const T max)
|
||||
{
|
||||
assert(min <= max);
|
||||
if (a <= min) return min;
|
||||
@@ -99,7 +99,7 @@ static inline T Clamp(const T a, const T min, const T max)
|
||||
* @returns A value between min and max which is closest to a.
|
||||
*/
|
||||
template <typename T>
|
||||
static inline T SoftClamp(const T a, const T min, const T max)
|
||||
inline T SoftClamp(const T a, const T min, const T max)
|
||||
{
|
||||
if (min > max) {
|
||||
using U = std::make_unsigned_t<T>;
|
||||
@@ -126,7 +126,7 @@ static inline T SoftClamp(const T a, const T min, const T max)
|
||||
* @returns A value between min and max which is closest to a.
|
||||
* @see ClampU(uint, uint, uint)
|
||||
*/
|
||||
static inline int Clamp(const int a, const int min, const int max)
|
||||
inline int Clamp(const int a, const int min, const int max)
|
||||
{
|
||||
return Clamp<int>(a, min, max);
|
||||
}
|
||||
@@ -147,7 +147,7 @@ static inline int Clamp(const int a, const int min, const int max)
|
||||
* @returns A value between min and max which is closest to a.
|
||||
* @see Clamp(int, int, int)
|
||||
*/
|
||||
static inline uint ClampU(const uint a, const uint min, const uint max)
|
||||
inline uint ClampU(const uint a, const uint min, const uint max)
|
||||
{
|
||||
return Clamp<uint>(a, min, max);
|
||||
}
|
||||
@@ -231,7 +231,7 @@ constexpr To ClampTo(From value)
|
||||
* @return The absolute difference between the given scalars
|
||||
*/
|
||||
template <typename T>
|
||||
static inline T Delta(const T a, const T b)
|
||||
inline T Delta(const T a, const T b)
|
||||
{
|
||||
return (a < b) ? b - a : a - b;
|
||||
}
|
||||
@@ -249,7 +249,7 @@ static inline T Delta(const T a, const T b)
|
||||
* @return True if the value is in the interval, false else.
|
||||
*/
|
||||
template <typename T>
|
||||
static inline bool IsInsideBS(const T x, const size_t base, const size_t size)
|
||||
inline bool IsInsideBS(const T x, const size_t base, const size_t size)
|
||||
{
|
||||
return (size_t)(x - base) < size;
|
||||
}
|
||||
@@ -280,7 +280,7 @@ static constexpr inline bool IsInsideMM(const T x, const size_t min, const size_
|
||||
* @param b variable to swap with a
|
||||
*/
|
||||
template <typename T>
|
||||
static inline void Swap(T &a, T &b)
|
||||
inline void Swap(T &a, T &b)
|
||||
{
|
||||
T t = a;
|
||||
a = b;
|
||||
@@ -292,7 +292,7 @@ static inline void Swap(T &a, T &b)
|
||||
* @param i value to convert, range 0..255
|
||||
* @return value in range 0..100
|
||||
*/
|
||||
static inline uint ToPercent8(uint i)
|
||||
inline uint ToPercent8(uint i)
|
||||
{
|
||||
assert(i < 256);
|
||||
return i * 101 >> 8;
|
||||
@@ -303,7 +303,7 @@ static inline uint ToPercent8(uint i)
|
||||
* @param i value to convert, range 0..65535
|
||||
* @return value in range 0..100
|
||||
*/
|
||||
static inline uint ToPercent16(uint i)
|
||||
inline uint ToPercent16(uint i)
|
||||
{
|
||||
assert(i < 65536);
|
||||
return i * 101 >> 16;
|
||||
@@ -319,7 +319,7 @@ int DivideApprox(int a, int b);
|
||||
* @param b Denominator
|
||||
* @return Quotient, rounded up
|
||||
*/
|
||||
static inline uint CeilDiv(uint a, uint b)
|
||||
inline uint CeilDiv(uint a, uint b)
|
||||
{
|
||||
return (a + b - 1) / b;
|
||||
}
|
||||
@@ -330,7 +330,7 @@ static inline uint CeilDiv(uint a, uint b)
|
||||
* @param b Denominator
|
||||
* @return a rounded up to the nearest multiple of b.
|
||||
*/
|
||||
static inline uint Ceil(uint a, uint b)
|
||||
inline uint Ceil(uint a, uint b)
|
||||
{
|
||||
return CeilDiv(a, b) * b;
|
||||
}
|
||||
@@ -341,7 +341,7 @@ static inline uint Ceil(uint a, uint b)
|
||||
* @param b Denominator
|
||||
* @return Quotient, rounded to nearest
|
||||
*/
|
||||
static inline int RoundDivSU(int a, uint b)
|
||||
inline int RoundDivSU(int a, uint b)
|
||||
{
|
||||
if (a > 0) {
|
||||
/* 0.5 is rounded to 1 */
|
||||
@@ -358,7 +358,7 @@ static inline int RoundDivSU(int a, uint b)
|
||||
* @param b Denominator
|
||||
* @return Quotient, rounded away from zero
|
||||
*/
|
||||
static inline int DivAwayFromZero(int a, uint b)
|
||||
inline int DivAwayFromZero(int a, uint b)
|
||||
{
|
||||
const int _b = static_cast<int>(b);
|
||||
if (a > 0) {
|
||||
|
@@ -20,7 +20,7 @@
|
||||
* @param num number of items to be copied. (!not number of bytes!)
|
||||
*/
|
||||
template <typename T>
|
||||
static inline void MemCpyT(T *destination, const T *source, size_t num = 1)
|
||||
inline void MemCpyT(T *destination, const T *source, size_t num = 1)
|
||||
{
|
||||
memcpy(destination, source, num * sizeof(T));
|
||||
}
|
||||
@@ -33,7 +33,7 @@ static inline void MemCpyT(T *destination, const T *source, size_t num = 1)
|
||||
* @param num number of items to be copied. (!not number of bytes!)
|
||||
*/
|
||||
template <typename T>
|
||||
static inline void MemMoveT(T *destination, const T *source, size_t num = 1)
|
||||
inline void MemMoveT(T *destination, const T *source, size_t num = 1)
|
||||
{
|
||||
memmove(destination, source, num * sizeof(T));
|
||||
}
|
||||
@@ -46,7 +46,7 @@ static inline void MemMoveT(T *destination, const T *source, size_t num = 1)
|
||||
* @param num number of items to be set (!not number of bytes!)
|
||||
*/
|
||||
template <typename T>
|
||||
static inline void MemSetT(T *ptr, byte value, size_t num = 1)
|
||||
inline void MemSetT(T *ptr, byte value, size_t num = 1)
|
||||
{
|
||||
memset(ptr, value, num * sizeof(T));
|
||||
}
|
||||
@@ -60,7 +60,7 @@ static inline void MemSetT(T *ptr, byte value, size_t num = 1)
|
||||
* @return an int value indicating the relationship between the content of the two buffers
|
||||
*/
|
||||
template <typename T>
|
||||
static inline int MemCmpT(const T *ptr1, const T *ptr2, size_t num = 1)
|
||||
inline int MemCmpT(const T *ptr1, const T *ptr2, size_t num = 1)
|
||||
{
|
||||
return memcmp(ptr1, ptr2, num * sizeof(T));
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ struct SavedRandomSeeds {
|
||||
* Saves the current seeds
|
||||
* @param storage Storage for saving
|
||||
*/
|
||||
static inline void SaveRandomSeeds(SavedRandomSeeds *storage)
|
||||
inline void SaveRandomSeeds(SavedRandomSeeds *storage)
|
||||
{
|
||||
storage->random = _random;
|
||||
storage->interactive_random = _interactive_random;
|
||||
@@ -49,7 +49,7 @@ static inline void SaveRandomSeeds(SavedRandomSeeds *storage)
|
||||
* Restores previously saved seeds
|
||||
* @param storage Storage where SaveRandomSeeds() stored th seeds
|
||||
*/
|
||||
static inline void RestoreRandomSeeds(const SavedRandomSeeds &storage)
|
||||
inline void RestoreRandomSeeds(const SavedRandomSeeds &storage)
|
||||
{
|
||||
_random = storage.random;
|
||||
_interactive_random = storage.interactive_random;
|
||||
@@ -84,12 +84,12 @@ void SetRandomSeed(uint32_t seed);
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline uint32_t InteractiveRandom()
|
||||
inline uint32_t InteractiveRandom()
|
||||
{
|
||||
return _interactive_random.Next();
|
||||
}
|
||||
|
||||
static inline uint32_t InteractiveRandomRange(uint32_t limit)
|
||||
inline uint32_t InteractiveRandomRange(uint32_t limit)
|
||||
{
|
||||
return _interactive_random.Next(limit);
|
||||
}
|
||||
@@ -109,7 +109,7 @@ static inline uint32_t InteractiveRandomRange(uint32_t limit)
|
||||
* @param r The given randomize-number
|
||||
* @return True if the probability given by r is less or equal to (a/b)
|
||||
*/
|
||||
static inline bool Chance16I(const uint a, const uint b, const uint32_t r)
|
||||
inline bool Chance16I(const uint a, const uint b, const uint32_t r)
|
||||
{
|
||||
assert(b != 0);
|
||||
return (((uint16_t)r * b + b / 2) >> 16) < a;
|
||||
@@ -128,7 +128,7 @@ static inline bool Chance16I(const uint a, const uint b, const uint32_t r)
|
||||
#ifdef RANDOM_DEBUG
|
||||
# define Chance16(a, b) Chance16I(a, b, DoRandom(__LINE__, __FILE__))
|
||||
#else
|
||||
static inline bool Chance16(const uint a, const uint b)
|
||||
inline bool Chance16(const uint a, const uint b)
|
||||
{
|
||||
return Chance16I(a, b, Random());
|
||||
}
|
||||
@@ -152,7 +152,7 @@ static inline bool Chance16(const uint a, const uint b)
|
||||
#ifdef RANDOM_DEBUG
|
||||
# define Chance16R(a, b, r) (r = DoRandom(__LINE__, __FILE__), Chance16I(a, b, r))
|
||||
#else
|
||||
static inline bool Chance16R(const uint a, const uint b, uint32_t &r)
|
||||
inline bool Chance16R(const uint a, const uint b, uint32_t &r)
|
||||
{
|
||||
r = Random();
|
||||
return Chance16I(a, b, r);
|
||||
|
Reference in New Issue
Block a user