mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-21 12:47:07 +00:00
refactor(src/common): remove unused imports (#19506)
* refactor(src/common): remove unused imports * fix: build * chore: fix build * chore: size_t -> std::size_t * chore: fix fuckup from previous commit * chore: fix build * chore: fix build * chore: fix build * chore: fix build with std::size_t * chore: fix build * chore: fix build * chore: fix build * chore: fix build * chore: fix build * chore: fix build * chore: fix build * chore: fix build * chore: fix build * chore: fix build * chore: fix build * chore: fix build
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
#ifndef AsyncCallbackProcessor_h__
|
||||
#define AsyncCallbackProcessor_h__
|
||||
|
||||
#include "Define.h"
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
namespace ByteConverter
|
||||
{
|
||||
template<size_t T>
|
||||
template<std::size_t T>
|
||||
inline void convert(char* val)
|
||||
{
|
||||
std::swap(*val, *(val + T - 1));
|
||||
|
||||
@@ -17,7 +17,7 @@ template <typename T>
|
||||
class CircularBuffer
|
||||
{
|
||||
public:
|
||||
explicit CircularBuffer(size_t size) :
|
||||
explicit CircularBuffer(std::size_t size) :
|
||||
buf_(std::unique_ptr<T[]>(new T[size])),
|
||||
max_size_(size)
|
||||
{
|
||||
@@ -52,14 +52,14 @@ public:
|
||||
return full_;
|
||||
}
|
||||
|
||||
[[nodiscard]] size_t capacity() const
|
||||
[[nodiscard]] std::size_t capacity() const
|
||||
{
|
||||
return max_size_;
|
||||
}
|
||||
|
||||
[[nodiscard]] size_t size() const
|
||||
[[nodiscard]] std::size_t size() const
|
||||
{
|
||||
size_t size = max_size_;
|
||||
std::size_t size = max_size_;
|
||||
|
||||
if (!full_)
|
||||
{
|
||||
@@ -95,9 +95,9 @@ public:
|
||||
private:
|
||||
std::mutex mutex_;
|
||||
std::unique_ptr<T[]> buf_;
|
||||
size_t head_ = 0;
|
||||
size_t tail_ = 0;
|
||||
const size_t max_size_;
|
||||
std::size_t head_ = 0;
|
||||
std::size_t tail_ = 0;
|
||||
const std::size_t max_size_;
|
||||
bool full_ = false;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <stdexcept>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace Acore
|
||||
@@ -51,13 +49,13 @@ namespace Acore
|
||||
using reference = T&;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
|
||||
CheckedBufferOutputIterator(T* buf, size_t n) : _buf(buf), _end(buf + n) {}
|
||||
CheckedBufferOutputIterator(T* buf, std::size_t n) : _buf(buf), _end(buf + n) {}
|
||||
|
||||
T& operator*() const { check(); return *_buf; }
|
||||
CheckedBufferOutputIterator& operator++() { check(); ++_buf; return *this; }
|
||||
CheckedBufferOutputIterator operator++(int) { CheckedBufferOutputIterator v = *this; operator++(); return v; }
|
||||
|
||||
[[nodiscard]] size_t remaining() const { return (_end - _buf); }
|
||||
[[nodiscard]] std::size_t remaining() const { return (_end - _buf); }
|
||||
|
||||
private:
|
||||
T* _buf;
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "Duration.h"
|
||||
#include "Random.h"
|
||||
#include <map>
|
||||
#include <type_traits>
|
||||
|
||||
class EventProcessor;
|
||||
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
#ifndef _ACORE_GEOMETRY_H
|
||||
#define _ACORE_GEOMETRY_H
|
||||
|
||||
#include "Define.h"
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
|
||||
[[nodiscard]] inline float getAngle(float startX, float startY, float destX, float destY)
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#ifndef IteratorPair_h__
|
||||
#define IteratorPair_h__
|
||||
|
||||
#include "Define.h"
|
||||
#include <utility>
|
||||
|
||||
namespace Acore
|
||||
|
||||
@@ -58,7 +58,7 @@ inline T mean(Container&& c)
|
||||
template <typename T>
|
||||
inline T median(std::vector<T> a)
|
||||
{
|
||||
size_t n = a.size();
|
||||
std::size_t n = a.size();
|
||||
// If size of the arr[] is even
|
||||
if (n % 2 == 0)
|
||||
{
|
||||
|
||||
@@ -25,9 +25,6 @@
|
||||
#define _ACORE_PHYSICS_H
|
||||
|
||||
#include "Geometry.h"
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ double rand_chance()
|
||||
return urd(engine);
|
||||
}
|
||||
|
||||
uint32 urandweighted(size_t count, double const* chances)
|
||||
uint32 urandweighted(std::size_t count, double const* chances)
|
||||
{
|
||||
std::discrete_distribution<uint32> dd(chances, chances + count);
|
||||
return dd(engine);
|
||||
|
||||
@@ -47,7 +47,7 @@ AC_COMMON_API double rand_norm();
|
||||
AC_COMMON_API double rand_chance();
|
||||
|
||||
/* Return a random number in the range 0..count (exclusive) with each value having a different chance of happening */
|
||||
AC_COMMON_API uint32 urandweighted(size_t count, double const* chances);
|
||||
AC_COMMON_API uint32 urandweighted(std::size_t count, double const* chances);
|
||||
|
||||
/* Return true if a random roll fits in the specified chance (range 0-100). */
|
||||
inline bool roll_chance_f(float chance)
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <mm_malloc.h>
|
||||
#elif defined(__GNUC__)
|
||||
static __inline__ void *__attribute__((__always_inline__, __nodebug__, __malloc__))
|
||||
_mm_malloc(size_t __size, size_t __align)
|
||||
_mm_malloc(std::size_t __size, std::size_t __align)
|
||||
{
|
||||
if (__align == 1)
|
||||
{
|
||||
@@ -78,7 +78,7 @@ uint32 SFMTRand::RandomUInt32() // Output random bits
|
||||
return sfmt_genrand_uint32(&_state);
|
||||
}
|
||||
|
||||
void* SFMTRand::operator new(size_t size, std::nothrow_t const&)
|
||||
void* SFMTRand::operator new(std::size_t size, std::nothrow_t const&)
|
||||
{
|
||||
return _mm_malloc(size, 16);
|
||||
}
|
||||
@@ -88,7 +88,7 @@ void SFMTRand::operator delete(void* ptr, std::nothrow_t const&)
|
||||
_mm_free(ptr);
|
||||
}
|
||||
|
||||
void* SFMTRand::operator new(size_t size)
|
||||
void* SFMTRand::operator new(std::size_t size)
|
||||
{
|
||||
return _mm_malloc(size, 16);
|
||||
}
|
||||
@@ -98,7 +98,7 @@ void SFMTRand::operator delete(void* ptr)
|
||||
_mm_free(ptr);
|
||||
}
|
||||
|
||||
void* SFMTRand::operator new[](size_t size, std::nothrow_t const&)
|
||||
void* SFMTRand::operator new[](std::size_t size, std::nothrow_t const&)
|
||||
{
|
||||
return _mm_malloc(size, 16);
|
||||
}
|
||||
@@ -108,7 +108,7 @@ void SFMTRand::operator delete[](void* ptr, std::nothrow_t const&)
|
||||
_mm_free(ptr);
|
||||
}
|
||||
|
||||
void* SFMTRand::operator new[](size_t size)
|
||||
void* SFMTRand::operator new[](std::size_t size)
|
||||
{
|
||||
return _mm_malloc(size, 16);
|
||||
}
|
||||
|
||||
@@ -30,13 +30,13 @@ class SFMTRand
|
||||
public:
|
||||
SFMTRand();
|
||||
uint32 RandomUInt32(); // Output random bits
|
||||
void* operator new(size_t size, std::nothrow_t const&);
|
||||
void* operator new(std::size_t size, std::nothrow_t const&);
|
||||
void operator delete(void* ptr, std::nothrow_t const&);
|
||||
void* operator new(size_t size);
|
||||
void* operator new(std::size_t size);
|
||||
void operator delete(void* ptr);
|
||||
void* operator new[](size_t size, std::nothrow_t const&);
|
||||
void* operator new[](std::size_t size, std::nothrow_t const&);
|
||||
void operator delete[](void* ptr, std::nothrow_t const&);
|
||||
void* operator new[](size_t size);
|
||||
void* operator new[](std::size_t size);
|
||||
void operator delete[](void* ptr);
|
||||
private:
|
||||
sfmt_t _state;
|
||||
|
||||
@@ -37,10 +37,10 @@ namespace Acore::Impl::EnumUtilsImpl
|
||||
template <typename Enum>
|
||||
struct EnumUtils
|
||||
{
|
||||
static size_t Count();
|
||||
static std::size_t Count();
|
||||
static EnumText ToString(Enum value);
|
||||
static Enum FromIndex(size_t index);
|
||||
static size_t ToIndex(Enum index);
|
||||
static Enum FromIndex(std::size_t index);
|
||||
static std::size_t ToIndex(Enum index);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -48,11 +48,11 @@ class EnumUtils
|
||||
{
|
||||
public:
|
||||
template <typename Enum>
|
||||
static size_t Count() { return Acore::Impl::EnumUtilsImpl::EnumUtils<Enum>::Count(); }
|
||||
static std::size_t Count() { return Acore::Impl::EnumUtilsImpl::EnumUtils<Enum>::Count(); }
|
||||
template <typename Enum>
|
||||
static EnumText ToString(Enum value) { return Acore::Impl::EnumUtilsImpl::EnumUtils<Enum>::ToString(value); }
|
||||
template <typename Enum>
|
||||
static Enum FromIndex(size_t index) { return Acore::Impl::EnumUtilsImpl::EnumUtils<Enum>::FromIndex(index); }
|
||||
static Enum FromIndex(std::size_t index) { return Acore::Impl::EnumUtilsImpl::EnumUtils<Enum>::FromIndex(index); }
|
||||
template <typename Enum>
|
||||
static uint32 ToIndex(Enum value) { return Acore::Impl::EnumUtilsImpl::EnumUtils<Enum>::ToIndex(value);}
|
||||
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
using difference_type = std::ptrdiff_t;
|
||||
|
||||
Iterator() : _index(EnumUtils::Count<Enum>()) {}
|
||||
explicit Iterator(size_t index) : _index(index) { }
|
||||
explicit Iterator(std::size_t index) : _index(index) { }
|
||||
|
||||
bool operator==(const Iterator& other) const { return other._index == _index; }
|
||||
bool operator!=(const Iterator& other) const { return !operator==(other); }
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
#include "Define.h"
|
||||
#include <future>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ namespace Acore::Impl::StringConvertImpl
|
||||
}
|
||||
tmp.append(str);
|
||||
|
||||
size_t n;
|
||||
std::size_t n;
|
||||
T val = static_cast<T>(std::stold(tmp, &n));
|
||||
if (n != tmp.length())
|
||||
{
|
||||
|
||||
@@ -31,7 +31,7 @@ TaskScheduler& TaskScheduler::Update(success_t const& callback)
|
||||
return *this;
|
||||
}
|
||||
|
||||
TaskScheduler& TaskScheduler::Update(size_t const milliseconds, success_t const& callback)
|
||||
TaskScheduler& TaskScheduler::Update(std::size_t const milliseconds, success_t const& callback)
|
||||
{
|
||||
return Update(std::chrono::milliseconds(milliseconds), callback);
|
||||
}
|
||||
|
||||
@@ -19,14 +19,11 @@
|
||||
#define _TASK_SCHEDULER_H_
|
||||
|
||||
#include "Util.h"
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <queue>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
class TaskContext;
|
||||
@@ -209,7 +206,7 @@ public:
|
||||
|
||||
/// Update the scheduler with a difftime in ms.
|
||||
/// Calls the optional callback on successfully finish.
|
||||
TaskScheduler& Update(size_t const milliseconds, success_t const& callback = EmptyCallback);
|
||||
TaskScheduler& Update(std::size_t const milliseconds, success_t const& callback = EmptyCallback);
|
||||
|
||||
/// Update the scheduler with a difftime.
|
||||
/// Calls the optional callback on successfully finish.
|
||||
|
||||
@@ -21,8 +21,8 @@ std::vector<std::string_view> Acore::Tokenize(std::string_view str, char sep, bo
|
||||
{
|
||||
std::vector<std::string_view> tokens;
|
||||
|
||||
size_t start = 0;
|
||||
for (size_t end = str.find(sep); end != std::string_view::npos; end = str.find(sep, start))
|
||||
std::size_t start = 0;
|
||||
for (std::size_t end = str.find(sep); end != std::string_view::npos; end = str.find(sep, start))
|
||||
{
|
||||
if (keepEmpty || (start < end))
|
||||
{
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#ifndef _ACORE_TOKENIZE_H_
|
||||
#define _ACORE_TOKENIZE_H_
|
||||
|
||||
#include "Common.h"
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Acore
|
||||
|
||||
namespace Impl
|
||||
{
|
||||
template <class T, class Tuple, size_t... I>
|
||||
template <class T, class Tuple, std::size_t... I>
|
||||
T* new_from_tuple(Tuple&& args, std::index_sequence<I...>)
|
||||
{
|
||||
return new T(std::get<I>(std::forward<Tuple>(args))...);
|
||||
|
||||
@@ -33,10 +33,10 @@ void stripLineInvisibleChars(std::string& str)
|
||||
{
|
||||
static std::string const invChars = " \t\7\n";
|
||||
|
||||
size_t wpos = 0;
|
||||
std::size_t wpos = 0;
|
||||
|
||||
bool space = false;
|
||||
for (size_t pos = 0; pos < str.size(); ++pos)
|
||||
for (std::size_t pos = 0; pos < str.size(); ++pos)
|
||||
{
|
||||
if (invChars.find(str[pos]) != std::string::npos)
|
||||
{
|
||||
@@ -242,7 +242,7 @@ uint32 GetPID()
|
||||
return uint32(pid);
|
||||
}
|
||||
|
||||
size_t utf8length(std::string& utf8str)
|
||||
std::size_t utf8length(std::string& utf8str)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -255,11 +255,11 @@ size_t utf8length(std::string& utf8str)
|
||||
}
|
||||
}
|
||||
|
||||
void utf8truncate(std::string& utf8str, size_t len)
|
||||
void utf8truncate(std::string& utf8str, std::size_t len)
|
||||
{
|
||||
try
|
||||
{
|
||||
size_t wlen = utf8::distance(utf8str.c_str(), utf8str.c_str() + utf8str.size());
|
||||
std::size_t wlen = utf8::distance(utf8str.c_str(), utf8str.c_str() + utf8str.size());
|
||||
if (wlen <= len)
|
||||
{
|
||||
return;
|
||||
@@ -278,7 +278,7 @@ void utf8truncate(std::string& utf8str, size_t len)
|
||||
}
|
||||
}
|
||||
|
||||
bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize)
|
||||
bool Utf8toWStr(char const* utf8str, std::size_t csize, wchar_t* wstr, std::size_t& wsize)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -330,7 +330,7 @@ bool Utf8toWStr(std::string_view utf8str, std::wstring& wstr)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WStrToUtf8(wchar_t const* wstr, size_t size, std::string& utf8str)
|
||||
bool WStrToUtf8(wchar_t const* wstr, std::size_t size, std::string& utf8str)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -512,14 +512,14 @@ void vutf8printf(FILE* out, const char* str, va_list* ap)
|
||||
char temp_buf[32 * 1024];
|
||||
wchar_t wtemp_buf[32 * 1024];
|
||||
|
||||
size_t temp_len = vsnprintf(temp_buf, 32 * 1024, str, *ap);
|
||||
std::size_t temp_len = vsnprintf(temp_buf, 32 * 1024, str, *ap);
|
||||
//vsnprintf returns -1 if the buffer is too small
|
||||
if (temp_len == size_t(-1))
|
||||
if (temp_len == std::size_t(-1))
|
||||
{
|
||||
temp_len = 32 * 1024 - 1;
|
||||
}
|
||||
|
||||
size_t wtemp_len = 32 * 1024 - 1;
|
||||
std::size_t wtemp_len = 32 * 1024 - 1;
|
||||
Utf8toWStr(temp_buf, temp_len, wtemp_buf, wtemp_len);
|
||||
|
||||
CharToOemBuffW(&wtemp_buf[0], &temp_buf[0], uint32(wtemp_len + 1));
|
||||
@@ -542,7 +542,7 @@ bool Utf8ToUpperOnlyLatin(std::string& utf8String)
|
||||
return WStrToUtf8(wstr, utf8String);
|
||||
}
|
||||
|
||||
std::string Acore::Impl::ByteArrayToHexStr(uint8 const* bytes, size_t arrayLen, bool reverse /* = false */)
|
||||
std::string Acore::Impl::ByteArrayToHexStr(uint8 const* bytes, std::size_t arrayLen, bool reverse /* = false */)
|
||||
{
|
||||
int32 init = 0;
|
||||
int32 end = arrayLen;
|
||||
@@ -566,7 +566,7 @@ std::string Acore::Impl::ByteArrayToHexStr(uint8 const* bytes, size_t arrayLen,
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void Acore::Impl::HexStrToByteArray(std::string_view str, uint8* out, size_t outlen, bool reverse /*= false*/)
|
||||
void Acore::Impl::HexStrToByteArray(std::string_view str, uint8* out, std::size_t outlen, bool reverse /*= false*/)
|
||||
{
|
||||
ASSERT(str.size() == (2 * outlen));
|
||||
|
||||
|
||||
@@ -85,9 +85,9 @@ inline T RoundToInterval(T& num, T floor, T ceil)
|
||||
AC_COMMON_API bool Utf8toWStr(std::string_view utf8str, std::wstring& wstr);
|
||||
|
||||
// in wsize==max size of buffer, out wsize==real string size
|
||||
AC_COMMON_API bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize);
|
||||
AC_COMMON_API bool Utf8toWStr(char const* utf8str, std::size_t csize, wchar_t* wstr, std::size_t& wsize);
|
||||
|
||||
inline bool Utf8toWStr(std::string_view utf8str, wchar_t* wstr, size_t& wsize)
|
||||
inline bool Utf8toWStr(std::string_view utf8str, wchar_t* wstr, std::size_t& wsize)
|
||||
{
|
||||
return Utf8toWStr(utf8str.data(), utf8str.size(), wstr, wsize);
|
||||
}
|
||||
@@ -95,11 +95,11 @@ inline bool Utf8toWStr(std::string_view utf8str, wchar_t* wstr, size_t& wsize)
|
||||
AC_COMMON_API bool WStrToUtf8(std::wstring_view wstr, std::string& utf8str);
|
||||
|
||||
// size==real string size
|
||||
AC_COMMON_API bool WStrToUtf8(wchar_t const* wstr, size_t size, std::string& utf8str);
|
||||
AC_COMMON_API bool WStrToUtf8(wchar_t const* wstr, std::size_t size, std::string& utf8str);
|
||||
|
||||
// set string to "" if invalid utf8 sequence
|
||||
size_t utf8length(std::string& utf8str);
|
||||
void utf8truncate(std::string& utf8str, size_t len);
|
||||
std::size_t utf8length(std::string& utf8str);
|
||||
void utf8truncate(std::string& utf8str, std::size_t len);
|
||||
|
||||
inline bool isBasicLatinCharacter(wchar_t wchar)
|
||||
{
|
||||
@@ -373,8 +373,8 @@ uint32 GetPID();
|
||||
|
||||
namespace Acore::Impl
|
||||
{
|
||||
AC_COMMON_API std::string ByteArrayToHexStr(uint8 const* bytes, size_t length, bool reverse = false);
|
||||
AC_COMMON_API void HexStrToByteArray(std::string_view str, uint8* out, size_t outlen, bool reverse = false);
|
||||
AC_COMMON_API std::string ByteArrayToHexStr(uint8 const* bytes, std::size_t length, bool reverse = false);
|
||||
AC_COMMON_API void HexStrToByteArray(std::string_view str, uint8* out, std::size_t outlen, bool reverse = false);
|
||||
}
|
||||
|
||||
template<typename Container>
|
||||
@@ -383,13 +383,13 @@ std::string ByteArrayToHexStr(Container const& c, bool reverse = false)
|
||||
return Acore::Impl::ByteArrayToHexStr(std::data(c), std::size(c), reverse);
|
||||
}
|
||||
|
||||
template<size_t Size>
|
||||
template<std::size_t Size>
|
||||
void HexStrToByteArray(std::string_view str, std::array<uint8, Size>& buf, bool reverse = false)
|
||||
{
|
||||
Acore::Impl::HexStrToByteArray(str, buf.data(), Size, reverse);
|
||||
}
|
||||
|
||||
template<size_t Size>
|
||||
template<std::size_t Size>
|
||||
std::array<uint8, Size> HexStrToByteArray(std::string_view str, bool reverse = false)
|
||||
{
|
||||
std::array<uint8, Size> arr;
|
||||
@@ -433,7 +433,7 @@ public:
|
||||
m_list.remove(t);
|
||||
return *this;
|
||||
}
|
||||
size_t size()
|
||||
std::size_t size()
|
||||
{
|
||||
return m_list.size();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user