From 1ae7cdd512a28a973aaa087f4516baca1cae665b Mon Sep 17 00:00:00 2001 From: Shauren Date: Wed, 11 Jun 2025 16:35:31 +0200 Subject: Core/Common: Update PCH content to include most commonly used headers --- src/common/Configuration/Config.cpp | 1 + .../Debugging/Windows/WheatyExceptionReport.h | 2 +- src/common/Logging/Log.cpp | 4 +--- src/common/Platform/Windows/ServiceWin32.cpp | 2 +- src/common/PrecompiledHeaders/commonPCH.h | 23 ++++++-------------- src/common/Time/Timezone.cpp | 25 +++++++++++----------- src/common/Utilities/StringConvert.h | 3 ++- src/common/Utilities/StringFormat.h | 2 +- 8 files changed, 26 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/common/Configuration/Config.cpp b/src/common/Configuration/Config.cpp index a0672d56ff6..946ff676e6f 100644 --- a/src/common/Configuration/Config.cpp +++ b/src/common/Configuration/Config.cpp @@ -19,6 +19,7 @@ #include "Common.h" #include "Log.h" #include "StringConvert.h" +#include "Util.h" #include #include #include diff --git a/src/common/Debugging/Windows/WheatyExceptionReport.h b/src/common/Debugging/Windows/WheatyExceptionReport.h index e24492bb5e2..27eb5753b27 100644 --- a/src/common/Debugging/Windows/WheatyExceptionReport.h +++ b/src/common/Debugging/Windows/WheatyExceptionReport.h @@ -5,7 +5,7 @@ #include "Define.h" #include "Optional.h" -#include +#include #include #include #include diff --git a/src/common/Logging/Log.cpp b/src/common/Logging/Log.cpp index b64aec29866..643f0c8483c 100644 --- a/src/common/Logging/Log.cpp +++ b/src/common/Logging/Log.cpp @@ -19,7 +19,6 @@ #include "AppenderConsole.h" #include "AppenderFile.h" #include "Config.h" -#include "Duration.h" #include "Errors.h" #include "LogMessage.h" #include "LogOperation.h" @@ -263,8 +262,7 @@ Logger const* Log::GetLoggerByType(std::string_view type) const std::string Log::GetTimestampStr() { - time_t tt = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); - return TimeToTimestampStr(tt); + return TimeToTimestampStr(time(nullptr)); } bool Log::SetLogLevel(std::string const& name, int32 newLeveli, bool isLogger /* = true */) diff --git a/src/common/Platform/Windows/ServiceWin32.cpp b/src/common/Platform/Windows/ServiceWin32.cpp index 80914d2a415..f536d4b6e4a 100644 --- a/src/common/Platform/Windows/ServiceWin32.cpp +++ b/src/common/Platform/Windows/ServiceWin32.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include namespace diff --git a/src/common/PrecompiledHeaders/commonPCH.h b/src/common/PrecompiledHeaders/commonPCH.h index dfd7e51f82f..ba41f2657bf 100644 --- a/src/common/PrecompiledHeaders/commonPCH.h +++ b/src/common/PrecompiledHeaders/commonPCH.h @@ -15,28 +15,19 @@ * with this program. If not, see . */ -#include "BoundingIntervalHierarchy.h" #include "Common.h" -#include "Config.h" #include "Define.h" +#include "Duration.h" #include "Errors.h" -#include "GitRevision.h" #include "Log.h" -#include "LogMessage.h" -#include "MapTree.h" -#include "ModelInstance.h" -#include "StringConvert.h" -#include "Util.h" -#include "VMapDefinitions.h" #include "WorldModel.h" -#include +#include #include +#include #include -#include #include -#include -#include -#include -#include -#include #include + +#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS +#include +#endif diff --git a/src/common/Time/Timezone.cpp b/src/common/Time/Timezone.cpp index 5cd80d03232..6c9e58e0c93 100644 --- a/src/common/Time/Timezone.cpp +++ b/src/common/Time/Timezone.cpp @@ -17,13 +17,19 @@ #include "Timezone.h" #include "Hash.h" -#include "Locales.h" #include "MapUtils.h" +#include "Tuples.h" +#include +#include + +#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS #include "StringConvert.h" +#else +#include "Locales.h" +#include "Util.h" #include -#include #include -#include +#endif namespace { @@ -163,20 +169,13 @@ std::string GetSystemZoneName() std::string_view FindClosestClientSupportedTimezone(std::string_view currentTimezone, Minutes currentTimezoneOffset) { // try exact match - auto itr = std::find_if(_clientSupportedTimezones.begin(), _clientSupportedTimezones.end(), [currentTimezone](ClientSupportedTimezone const& tz) - { - return tz.second == currentTimezone; - }); + auto itr = std::ranges::find(_clientSupportedTimezones, currentTimezone, Trinity::TupleElement<1>); if (itr != _clientSupportedTimezones.end()) return itr->second; // try closest offset - itr = std::min_element(_clientSupportedTimezones.begin(), _clientSupportedTimezones.end(), [currentTimezoneOffset](ClientSupportedTimezone const& left, ClientSupportedTimezone const& right) - { - Minutes leftDiff = left.first - currentTimezoneOffset; - Minutes rightDiff = right.first - currentTimezoneOffset; - return std::abs(leftDiff.count()) < std::abs(rightDiff.count()); - }); + itr = std::ranges::min_element(_clientSupportedTimezones, std::ranges::less(), + [currentTimezoneOffset](ClientSupportedTimezone const& ctz) { return std::chrono::abs(ctz.first - currentTimezoneOffset); }); return itr->second; } diff --git a/src/common/Utilities/StringConvert.h b/src/common/Utilities/StringConvert.h index 0d11dbb6667..ebe33cee721 100644 --- a/src/common/Utilities/StringConvert.h +++ b/src/common/Utilities/StringConvert.h @@ -22,12 +22,13 @@ #include "Errors.h" #include "Optional.h" #include "Types.h" -#include "Util.h" #include #include #include #include +TC_COMMON_API bool StringEqualI(std::string_view str1, std::string_view str2); + namespace Trinity::Impl::StringConvertImpl { template struct For diff --git a/src/common/Utilities/StringFormat.h b/src/common/Utilities/StringFormat.h index 2016eab0ba3..f7f2b7c300b 100644 --- a/src/common/Utilities/StringFormat.h +++ b/src/common/Utilities/StringFormat.h @@ -125,6 +125,6 @@ struct fmt::formatter, Char> : formatter // allow implicit enum to int conversions for formatting template , std::nullptr_t> = nullptr> -auto format_as(E e) { return std::underlying_type_t(e); } +inline constexpr auto format_as(E e) { return static_cast>(e); } #endif -- cgit v1.2.3