From 18bb89262537810d5eb982eb5db4b0d4223679ef Mon Sep 17 00:00:00 2001 From: Vittorio Romeo Date: Sun, 19 Dec 2021 17:34:49 +0100 Subject: [PATCH] Improve compilation times by removing some includes and avoiding heavy dependencies --- examples/joystick/Joystick.cpp | 1 - examples/voip/Server.cpp | 1 - examples/voip/VoIP.cpp | 1 - extlibs/headers/glad/include/glad/wgl.h | 2 +- include/SFML/Audio/SoundFileReader.hpp | 1 - include/SFML/Graphics/RenderWindow.hpp | 1 - include/SFML/Network/IpAddress.hpp | 3 +-- include/SFML/System/Utf.hpp | 7 ++++++- include/SFML/System/Utf.inl | 21 +++++++++++++++------ include/SFML/Window/Clipboard.hpp | 3 ++- include/SFML/Window/WindowBase.hpp | 3 ++- src/SFML/Audio/AudioDevice.hpp | 1 - src/SFML/Audio/SoundFileReaderFlac.hpp | 1 - src/SFML/Audio/SoundFileReaderOgg.cpp | 1 - src/SFML/Audio/SoundFileReaderWav.hpp | 1 - src/SFML/Graphics/Text.cpp | 1 + src/SFML/Network/Http.cpp | 3 +-- src/SFML/Network/IpAddress.cpp | 2 ++ src/SFML/Network/UdpSocket.cpp | 2 +- src/SFML/System/Err.cpp | 1 + src/SFML/Window/Android/ClipboardImpl.cpp | 1 + src/SFML/Window/Android/ClipboardImpl.hpp | 7 ++----- src/SFML/Window/EGLCheck.cpp | 1 + src/SFML/Window/EGLCheck.hpp | 1 - src/SFML/Window/OSX/ClipboardImpl.hpp | 7 ++----- src/SFML/Window/OSX/ClipboardImpl.mm | 1 + src/SFML/Window/OSX/JoystickImpl.hpp | 1 - src/SFML/Window/OSX/WindowImplCocoa.hpp | 3 ++- src/SFML/Window/OSX/WindowImplCocoa.mm | 1 + src/SFML/Window/Unix/WindowImplX11.cpp | 1 + src/SFML/Window/Unix/WindowImplX11.hpp | 1 - src/SFML/Window/Win32/ClipboardImpl.hpp | 7 ++----- src/SFML/Window/Win32/JoystickImpl.cpp | 1 - src/SFML/Window/Win32/WindowImplWin32.cpp | 1 + src/SFML/Window/Win32/WindowImplWin32.hpp | 3 ++- src/SFML/Window/WindowImpl.hpp | 4 ++-- src/SFML/Window/iOS/ClipboardImpl.hpp | 7 ++----- src/SFML/Window/iOS/ClipboardImpl.mm | 1 + 38 files changed, 54 insertions(+), 52 deletions(-) diff --git a/examples/joystick/Joystick.cpp b/examples/joystick/Joystick.cpp index 6e1de3d0..06367742 100644 --- a/examples/joystick/Joystick.cpp +++ b/examples/joystick/Joystick.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include diff --git a/examples/voip/Server.cpp b/examples/voip/Server.cpp index 32ca1030..9012c77b 100644 --- a/examples/voip/Server.cpp +++ b/examples/voip/Server.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include diff --git a/examples/voip/VoIP.cpp b/examples/voip/VoIP.cpp index 06c37b74..1bf6b092 100644 --- a/examples/voip/VoIP.cpp +++ b/examples/voip/VoIP.cpp @@ -2,7 +2,6 @@ //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// -#include #include #include diff --git a/extlibs/headers/glad/include/glad/wgl.h b/extlibs/headers/glad/include/glad/wgl.h index 2c443ac8..a23c72e4 100644 --- a/extlibs/headers/glad/include/glad/wgl.h +++ b/extlibs/headers/glad/include/glad/wgl.h @@ -28,7 +28,7 @@ #ifndef SF_GLAD_WGL_H_ #define SF_GLAD_WGL_H_ -#include +#include #include #define SF_GLAD_WGL diff --git a/include/SFML/Audio/SoundFileReader.hpp b/include/SFML/Audio/SoundFileReader.hpp index 9a8804a8..116b60e1 100644 --- a/include/SFML/Audio/SoundFileReader.hpp +++ b/include/SFML/Audio/SoundFileReader.hpp @@ -29,7 +29,6 @@ // Headers //////////////////////////////////////////////////////////// #include -#include namespace sf diff --git a/include/SFML/Graphics/RenderWindow.hpp b/include/SFML/Graphics/RenderWindow.hpp index 0c7bdab7..3fc6c543 100644 --- a/include/SFML/Graphics/RenderWindow.hpp +++ b/include/SFML/Graphics/RenderWindow.hpp @@ -32,7 +32,6 @@ #include #include #include -#include namespace sf diff --git a/include/SFML/Network/IpAddress.hpp b/include/SFML/Network/IpAddress.hpp index 7ce59305..478847b4 100644 --- a/include/SFML/Network/IpAddress.hpp +++ b/include/SFML/Network/IpAddress.hpp @@ -30,8 +30,7 @@ //////////////////////////////////////////////////////////// #include #include -#include -#include +#include #include diff --git a/include/SFML/System/Utf.hpp b/include/SFML/System/Utf.hpp index 8b94b9aa..24064250 100644 --- a/include/SFML/System/Utf.hpp +++ b/include/SFML/System/Utf.hpp @@ -29,7 +29,6 @@ // Headers //////////////////////////////////////////////////////////// #include -#include #include #include #include @@ -37,6 +36,12 @@ namespace sf { +namespace priv +{ + template + OutputIt copy(InputIt first, InputIt last, OutputIt d_first); +} + template class Utf; diff --git a/include/SFML/System/Utf.inl b/include/SFML/System/Utf.inl index 8bd2ea10..360cea9c 100644 --- a/include/SFML/System/Utf.inl +++ b/include/SFML/System/Utf.inl @@ -35,6 +35,15 @@ //////////////////////////////////////////////////////////// +template +OutputIt priv::copy(InputIt first, InputIt last, OutputIt d_first) +{ + while (first != last) + *d_first++ = *first++; + + return d_first; +} + template In Utf<8>::decode(In begin, In end, Uint32& output, Uint32 replacement) { @@ -121,7 +130,7 @@ Out Utf<8>::encode(Uint32 input, Out output, Uint8 replacement) } // Add them to the output - output = std::copy(bytes, bytes + bytestoWrite, output); + output = priv::copy(bytes, bytes + bytestoWrite, output); } return output; @@ -244,7 +253,7 @@ Out Utf<8>::toLatin1(In begin, In end, Out output, char replacement) template Out Utf<8>::toUtf8(In begin, In end, Out output) { - return std::copy(begin, end, output); + return priv::copy(begin, end, output); } @@ -413,7 +422,7 @@ Out Utf<16>::fromLatin1(In begin, In end, Out output) { // Latin-1 is directly compatible with Unicode encodings, // and can thus be treated as (a sub-range of) UTF-32 - return std::copy(begin, end, output); + return priv::copy(begin, end, output); } @@ -482,7 +491,7 @@ Out Utf<16>::toUtf8(In begin, In end, Out output) template Out Utf<16>::toUtf16(In begin, In end, Out output) { - return std::copy(begin, end, output); + return priv::copy(begin, end, output); } @@ -563,7 +572,7 @@ Out Utf<32>::fromLatin1(In begin, In end, Out output) { // Latin-1 is directly compatible with Unicode encodings, // and can thus be treated as (a sub-range of) UTF-32 - return std::copy(begin, end, output); + return priv::copy(begin, end, output); } @@ -630,7 +639,7 @@ Out Utf<32>::toUtf16(In begin, In end, Out output) template Out Utf<32>::toUtf32(In begin, In end, Out output) { - return std::copy(begin, end, output); + return priv::copy(begin, end, output); } diff --git a/include/SFML/Window/Clipboard.hpp b/include/SFML/Window/Clipboard.hpp index cacf2a8c..697ecf9c 100644 --- a/include/SFML/Window/Clipboard.hpp +++ b/include/SFML/Window/Clipboard.hpp @@ -29,11 +29,12 @@ // Headers //////////////////////////////////////////////////////////// #include -#include namespace sf { +class String; + //////////////////////////////////////////////////////////// /// \brief Give access to the system clipboard /// diff --git a/include/SFML/Window/WindowBase.hpp b/include/SFML/Window/WindowBase.hpp index 72dbe557..9702537a 100644 --- a/include/SFML/Window/WindowBase.hpp +++ b/include/SFML/Window/WindowBase.hpp @@ -35,12 +35,13 @@ #include #include #include -#include #include namespace sf { +class String; + namespace priv { class WindowImpl; diff --git a/src/SFML/Audio/AudioDevice.hpp b/src/SFML/Audio/AudioDevice.hpp index 04a15622..4af32dda 100644 --- a/src/SFML/Audio/AudioDevice.hpp +++ b/src/SFML/Audio/AudioDevice.hpp @@ -29,7 +29,6 @@ // Headers //////////////////////////////////////////////////////////// #include -#include #include diff --git a/src/SFML/Audio/SoundFileReaderFlac.hpp b/src/SFML/Audio/SoundFileReaderFlac.hpp index ee0af643..c33d8d62 100644 --- a/src/SFML/Audio/SoundFileReaderFlac.hpp +++ b/src/SFML/Audio/SoundFileReaderFlac.hpp @@ -30,7 +30,6 @@ //////////////////////////////////////////////////////////// #include #include -#include #include diff --git a/src/SFML/Audio/SoundFileReaderOgg.cpp b/src/SFML/Audio/SoundFileReaderOgg.cpp index 84d6c228..99ff963d 100644 --- a/src/SFML/Audio/SoundFileReaderOgg.cpp +++ b/src/SFML/Audio/SoundFileReaderOgg.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include diff --git a/src/SFML/Audio/SoundFileReaderWav.hpp b/src/SFML/Audio/SoundFileReaderWav.hpp index b2534259..4fc7ead7 100644 --- a/src/SFML/Audio/SoundFileReaderWav.hpp +++ b/src/SFML/Audio/SoundFileReaderWav.hpp @@ -29,7 +29,6 @@ // Headers //////////////////////////////////////////////////////////// #include -#include namespace sf diff --git a/src/SFML/Graphics/Text.cpp b/src/SFML/Graphics/Text.cpp index bd125840..7b514141 100644 --- a/src/SFML/Graphics/Text.cpp +++ b/src/SFML/Graphics/Text.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include diff --git a/src/SFML/Network/Http.cpp b/src/SFML/Network/Http.cpp index f6c2ff4e..739e51e0 100644 --- a/src/SFML/Network/Http.cpp +++ b/src/SFML/Network/Http.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -204,7 +203,7 @@ void Http::Response::parse(const std::string& data) { if ((version.size() >= 8) && (version[6] == '.') && (toLower(version.substr(0, 5)) == "http/") && - isdigit(version[5]) && isdigit(version[7])) + std::isdigit(version[5]) && std::isdigit(version[7])) { m_majorVersion = static_cast(version[5] - '0'); m_minorVersion = static_cast(version[7] - '0'); diff --git a/src/SFML/Network/IpAddress.cpp b/src/SFML/Network/IpAddress.cpp index 90d9e24d..5c07179b 100644 --- a/src/SFML/Network/IpAddress.cpp +++ b/src/SFML/Network/IpAddress.cpp @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include #include diff --git a/src/SFML/Network/UdpSocket.cpp b/src/SFML/Network/UdpSocket.cpp index 012f6877..40c8de62 100644 --- a/src/SFML/Network/UdpSocket.cpp +++ b/src/SFML/Network/UdpSocket.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include namespace sf diff --git a/src/SFML/System/Err.cpp b/src/SFML/System/Err.cpp index df371fe5..a1bd3057 100644 --- a/src/SFML/System/Err.cpp +++ b/src/SFML/System/Err.cpp @@ -26,6 +26,7 @@ // Headers //////////////////////////////////////////////////////////// #include +#include #include #include diff --git a/src/SFML/Window/Android/ClipboardImpl.cpp b/src/SFML/Window/Android/ClipboardImpl.cpp index 5aceb0e7..a82cba08 100644 --- a/src/SFML/Window/Android/ClipboardImpl.cpp +++ b/src/SFML/Window/Android/ClipboardImpl.cpp @@ -27,6 +27,7 @@ //////////////////////////////////////////////////////////// #include #include +#include namespace sf diff --git a/src/SFML/Window/Android/ClipboardImpl.hpp b/src/SFML/Window/Android/ClipboardImpl.hpp index f657ccb9..92c1f358 100644 --- a/src/SFML/Window/Android/ClipboardImpl.hpp +++ b/src/SFML/Window/Android/ClipboardImpl.hpp @@ -25,14 +25,11 @@ #ifndef SFML_CLIPBOARDIMPLANDROID_HPP #define SFML_CLIPBOARDIMPLANDROID_HPP -//////////////////////////////////////////////////////////// -// Headers -//////////////////////////////////////////////////////////// -#include - namespace sf { +class String; + namespace priv { //////////////////////////////////////////////////////////// diff --git a/src/SFML/Window/EGLCheck.cpp b/src/SFML/Window/EGLCheck.cpp index a5a4735f..8c5a659a 100644 --- a/src/SFML/Window/EGLCheck.cpp +++ b/src/SFML/Window/EGLCheck.cpp @@ -29,6 +29,7 @@ #include #include #include +#include namespace sf diff --git a/src/SFML/Window/EGLCheck.hpp b/src/SFML/Window/EGLCheck.hpp index 8eb6d0a2..367d3b70 100644 --- a/src/SFML/Window/EGLCheck.hpp +++ b/src/SFML/Window/EGLCheck.hpp @@ -29,7 +29,6 @@ // Headers //////////////////////////////////////////////////////////// #include -#include namespace sf diff --git a/src/SFML/Window/OSX/ClipboardImpl.hpp b/src/SFML/Window/OSX/ClipboardImpl.hpp index fa6987fb..cfb695cf 100644 --- a/src/SFML/Window/OSX/ClipboardImpl.hpp +++ b/src/SFML/Window/OSX/ClipboardImpl.hpp @@ -25,14 +25,11 @@ #ifndef SFML_CLIPBOARDIMPLCOCOA_HPP #define SFML_CLIPBOARDIMPLCOCOA_HPP -//////////////////////////////////////////////////////////// -// Headers -//////////////////////////////////////////////////////////// -#include - namespace sf { +class String; + namespace priv { diff --git a/src/SFML/Window/OSX/ClipboardImpl.mm b/src/SFML/Window/OSX/ClipboardImpl.mm index 858e35ac..2d4a56c0 100644 --- a/src/SFML/Window/OSX/ClipboardImpl.mm +++ b/src/SFML/Window/OSX/ClipboardImpl.mm @@ -27,6 +27,7 @@ //////////////////////////////////////////////////////////// #include #include +#include #import diff --git a/src/SFML/Window/OSX/JoystickImpl.hpp b/src/SFML/Window/OSX/JoystickImpl.hpp index b640769f..cef5faa9 100644 --- a/src/SFML/Window/OSX/JoystickImpl.hpp +++ b/src/SFML/Window/OSX/JoystickImpl.hpp @@ -30,7 +30,6 @@ // Headers //////////////////////////////////////////////////////////// #include -#include #include #include #include diff --git a/src/SFML/Window/OSX/WindowImplCocoa.hpp b/src/SFML/Window/OSX/WindowImplCocoa.hpp index 1662f512..028147ee 100644 --- a/src/SFML/Window/OSX/WindowImplCocoa.hpp +++ b/src/SFML/Window/OSX/WindowImplCocoa.hpp @@ -31,7 +31,6 @@ //////////////////////////////////////////////////////////// #include #include -#include //////////////////////////////////////////////////////////// /// Predefine OBJ-C classes @@ -55,6 +54,8 @@ using NSOpenGLContextRef = void*; namespace sf { +class String; + namespace priv { //////////////////////////////////////////////////////////// diff --git a/src/SFML/Window/OSX/WindowImplCocoa.mm b/src/SFML/Window/OSX/WindowImplCocoa.mm index 6cbc2736..4e6ef1d8 100644 --- a/src/SFML/Window/OSX/WindowImplCocoa.mm +++ b/src/SFML/Window/OSX/WindowImplCocoa.mm @@ -29,6 +29,7 @@ #include #include #include +#include #import #import diff --git a/src/SFML/Window/Unix/WindowImplX11.cpp b/src/SFML/Window/Unix/WindowImplX11.cpp index 7da831c4..196bbfe5 100644 --- a/src/SFML/Window/Unix/WindowImplX11.cpp +++ b/src/SFML/Window/Unix/WindowImplX11.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include diff --git a/src/SFML/Window/Unix/WindowImplX11.hpp b/src/SFML/Window/Unix/WindowImplX11.hpp index 1af56ab6..7ae189f9 100644 --- a/src/SFML/Window/Unix/WindowImplX11.hpp +++ b/src/SFML/Window/Unix/WindowImplX11.hpp @@ -30,7 +30,6 @@ //////////////////////////////////////////////////////////// #include #include -#include #include // Prevent conflict with macro None from Xlib #include #include diff --git a/src/SFML/Window/Win32/ClipboardImpl.hpp b/src/SFML/Window/Win32/ClipboardImpl.hpp index a7f63995..58a3dfae 100644 --- a/src/SFML/Window/Win32/ClipboardImpl.hpp +++ b/src/SFML/Window/Win32/ClipboardImpl.hpp @@ -25,14 +25,11 @@ #ifndef SFML_CLIPBOARDIMPLWIN32_HPP #define SFML_CLIPBOARDIMPLWIN32_HPP -//////////////////////////////////////////////////////////// -// Headers -//////////////////////////////////////////////////////////// -#include - namespace sf { +class String; + namespace priv { //////////////////////////////////////////////////////////// diff --git a/src/SFML/Window/Win32/JoystickImpl.cpp b/src/SFML/Window/Win32/JoystickImpl.cpp index c447bf19..07439942 100644 --- a/src/SFML/Window/Win32/JoystickImpl.cpp +++ b/src/SFML/Window/Win32/JoystickImpl.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include diff --git a/src/SFML/Window/Win32/WindowImplWin32.cpp b/src/SFML/Window/Win32/WindowImplWin32.cpp index f16f20ca..921abe77 100755 --- a/src/SFML/Window/Win32/WindowImplWin32.cpp +++ b/src/SFML/Window/Win32/WindowImplWin32.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include // dbt.h is lowercase here, as a cross-compile on linux with mingw-w64 // expects lowercase, and a native compile on windows, whether via msvc diff --git a/src/SFML/Window/Win32/WindowImplWin32.hpp b/src/SFML/Window/Win32/WindowImplWin32.hpp index 978871a5..46e5fd38 100755 --- a/src/SFML/Window/Win32/WindowImplWin32.hpp +++ b/src/SFML/Window/Win32/WindowImplWin32.hpp @@ -31,11 +31,12 @@ #include #include #include -#include namespace sf { +class String; + namespace priv { //////////////////////////////////////////////////////////// diff --git a/src/SFML/Window/WindowImpl.hpp b/src/SFML/Window/WindowImpl.hpp index c3d4a197..469dfe53 100644 --- a/src/SFML/Window/WindowImpl.hpp +++ b/src/SFML/Window/WindowImpl.hpp @@ -29,7 +29,6 @@ // Headers //////////////////////////////////////////////////////////// #include -#include #include #include #include @@ -37,13 +36,14 @@ #include #include #include +#include #include -#include #include #include namespace sf { +class String; class WindowListener; namespace priv diff --git a/src/SFML/Window/iOS/ClipboardImpl.hpp b/src/SFML/Window/iOS/ClipboardImpl.hpp index 65fd26e5..71c28b26 100644 --- a/src/SFML/Window/iOS/ClipboardImpl.hpp +++ b/src/SFML/Window/iOS/ClipboardImpl.hpp @@ -25,14 +25,11 @@ #ifndef SFML_CLIPBOARDIMPLIOS_HPP #define SFML_CLIPBOARDIMPLIOS_HPP -//////////////////////////////////////////////////////////// -// Headers -//////////////////////////////////////////////////////////// -#include - namespace sf { +class String; + namespace priv { diff --git a/src/SFML/Window/iOS/ClipboardImpl.mm b/src/SFML/Window/iOS/ClipboardImpl.mm index f857bf0f..26ebfa91 100644 --- a/src/SFML/Window/iOS/ClipboardImpl.mm +++ b/src/SFML/Window/iOS/ClipboardImpl.mm @@ -26,6 +26,7 @@ // Headers //////////////////////////////////////////////////////////// #include +#include #import