From 97c00d42adbc2934b09d6b6120f4188a80d4803c Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Sat, 15 Apr 2023 17:22:56 -0600 Subject: [PATCH] Enable clang-tidy `modernize-pass-by-value` check --- .clang-tidy | 1 - examples/shader/Effect.hpp | 3 ++- include/SFML/Graphics/Text.hpp | 4 ++-- include/SFML/Network/Ftp.hpp | 2 +- include/SFML/System/String.hpp | 2 +- src/SFML/Graphics/Text.cpp | 5 +++-- src/SFML/Network/Ftp.cpp | 3 ++- src/SFML/System/String.cpp | 3 ++- 8 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 18200714d..819e31d47 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -30,7 +30,6 @@ Checks: > -misc-non-private-member-variables-in-classes, -modernize-avoid-c-arrays, -modernize-macro-to-enum, - -modernize-pass-by-value, -modernize-return-braced-init-list, -modernize-use-nodiscard, -modernize-use-trailing-return-type, diff --git a/examples/shader/Effect.hpp b/examples/shader/Effect.hpp index 1b50d1fe8..55487137b 100644 --- a/examples/shader/Effect.hpp +++ b/examples/shader/Effect.hpp @@ -7,6 +7,7 @@ #include #include +#include //////////////////////////////////////////////////////////// @@ -54,7 +55,7 @@ public: } protected: - Effect(const std::string& name) : m_name(name) + Effect(std::string name) : m_name(std::move(name)) { } diff --git a/include/SFML/Graphics/Text.hpp b/include/SFML/Graphics/Text.hpp index fd244a6a4..eed583c9c 100644 --- a/include/SFML/Graphics/Text.hpp +++ b/include/SFML/Graphics/Text.hpp @@ -77,13 +77,13 @@ public: /// \param characterSize Base size of characters, in pixels /// //////////////////////////////////////////////////////////// - Text(const Font& font, const String& string = "", unsigned int characterSize = 30); + Text(const Font& font, String string = "", unsigned int characterSize = 30); //////////////////////////////////////////////////////////// /// \brief Disallow construction from a temporary font /// //////////////////////////////////////////////////////////// - Text(Font&& font, const String& string = "", unsigned int characterSize = 30) = delete; + Text(Font&& font, String string = "", unsigned int characterSize = 30) = delete; //////////////////////////////////////////////////////////// /// \brief Copy constructor diff --git a/include/SFML/Network/Ftp.hpp b/include/SFML/Network/Ftp.hpp index 1528b9890..4fe77770e 100644 --- a/include/SFML/Network/Ftp.hpp +++ b/include/SFML/Network/Ftp.hpp @@ -142,7 +142,7 @@ public: /// \param message Response message /// //////////////////////////////////////////////////////////// - explicit Response(Status code = Status::InvalidResponse, const std::string& message = ""); + explicit Response(Status code = Status::InvalidResponse, std::string message = ""); //////////////////////////////////////////////////////////// /// \brief Check if the status code means a success diff --git a/include/SFML/System/String.hpp b/include/SFML/System/String.hpp index 5d79e30a8..2641740ba 100644 --- a/include/SFML/System/String.hpp +++ b/include/SFML/System/String.hpp @@ -149,7 +149,7 @@ public: /// \param utf32String UTF-32 string to assign /// //////////////////////////////////////////////////////////// - String(const std::u32string& utf32String); + String(std::u32string utf32String); //////////////////////////////////////////////////////////// /// \brief Create a new sf::String from a UTF-8 encoded string diff --git a/src/SFML/Graphics/Text.cpp b/src/SFML/Graphics/Text.cpp index 93316778a..f1ecef46e 100644 --- a/src/SFML/Graphics/Text.cpp +++ b/src/SFML/Graphics/Text.cpp @@ -32,6 +32,7 @@ #include #include +#include namespace @@ -94,8 +95,8 @@ void addGlyphQuad(sf::VertexArray& vertices, sf::Vector2f position, const sf::Co namespace sf { //////////////////////////////////////////////////////////// -Text::Text(const Font& font, const String& string, unsigned int characterSize) : -m_string(string), +Text::Text(const Font& font, String string, unsigned int characterSize) : +m_string(std::move(string)), m_font(&font), m_characterSize(characterSize) { diff --git a/src/SFML/Network/Ftp.cpp b/src/SFML/Network/Ftp.cpp index 6b0a13a12..1b56300dd 100644 --- a/src/SFML/Network/Ftp.cpp +++ b/src/SFML/Network/Ftp.cpp @@ -36,6 +36,7 @@ #include #include #include +#include namespace sf @@ -78,7 +79,7 @@ private: //////////////////////////////////////////////////////////// -Ftp::Response::Response(Status code, const std::string& message) : m_status(code), m_message(message) +Ftp::Response::Response(Status code, std::string message) : m_status(code), m_message(std::move(message)) { } diff --git a/src/SFML/System/String.cpp b/src/SFML/System/String.cpp index f0ef7ab63..32333b5e1 100644 --- a/src/SFML/System/String.cpp +++ b/src/SFML/System/String.cpp @@ -30,6 +30,7 @@ #include #include +#include namespace sf @@ -118,7 +119,7 @@ String::String(const char32_t* utf32String) //////////////////////////////////////////////////////////// -String::String(const std::u32string& utf32String) : m_string(utf32String) +String::String(std::u32string utf32String) : m_string(std::move(utf32String)) { }