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 6e1de3d04..06367742a 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 32ca10302..9012c77bd 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 06c37b743..1bf6b0921 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 2c443ac84..a23c72e40 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 9a8804a89..116b60e18 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 0c7bdab7e..3fc6c543d 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 7ce593059..478847b4b 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 8b94b9aac..240642501 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 8bd2ea10d..360cea9c9 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 cacf2a8ca..697ecf9c5 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 72dbe5579..9702537a9 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 04a156226..4af32dda5 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 ee0af6436..c33d8d622 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 84d6c228a..99ff963de 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 b25342591..4fc7ead7e 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 bd125840b..7b5141412 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 f6c2ff4e1..739e51e05 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 90d9e24d9..5c07179b5 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 012f68779..40c8de62b 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 df371fe5e..a1bd30572 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 5aceb0e7a..a82cba089 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 f657ccb9f..92c1f3585 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 a5a4735f6..8c5a659ac 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 8eb6d0a22..367d3b70a 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 fa6987fbb..cfb695cf4 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 858e35ace..2d4a56c02 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 b640769ff..cef5faa9c 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 1662f512e..028147ee0 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 6cbc27365..4e6ef1d81 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 7da831c48..196bbfe5d 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 1af56ab6c..7ae189f93 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 a7f63995e..58a3dfae9 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 c447bf192..074399429 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 f16f20cab..921abe776 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 978871a5c..46e5fd386 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 c3d4a1977..469dfe530 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 65fd26e57..71c28b266 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 f857bf0f1..26ebfa914 100644 --- a/src/SFML/Window/iOS/ClipboardImpl.mm +++ b/src/SFML/Window/iOS/ClipboardImpl.mm @@ -26,6 +26,7 @@ // Headers //////////////////////////////////////////////////////////// #include +#include #import