From 9029118536289d0ad8ced6ee60fe5e95aa07e837 Mon Sep 17 00:00:00 2001 From: GermanAizek Date: Mon, 4 Jan 2021 23:54:14 +0300 Subject: [PATCH] Refactor code and declaration more local --- src/SFML/Audio/SoundFileWriterFlac.cpp | 2 +- src/SFML/Audio/SoundFileWriterOgg.cpp | 2 +- src/SFML/Audio/SoundFileWriterWav.cpp | 2 +- src/SFML/Network/Ftp.cpp | 2 +- src/SFML/Network/Http.cpp | 2 +- src/SFML/Window/WindowImpl.cpp | 3 ++- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/SFML/Audio/SoundFileWriterFlac.cpp b/src/SFML/Audio/SoundFileWriterFlac.cpp index ddd3c20a..79811655 100644 --- a/src/SFML/Audio/SoundFileWriterFlac.cpp +++ b/src/SFML/Audio/SoundFileWriterFlac.cpp @@ -39,7 +39,7 @@ namespace priv //////////////////////////////////////////////////////////// bool SoundFileWriterFlac::check(const std::string& filename) { - std::string extension = filename.substr(filename.find_last_of(".") + 1); + std::string extension = filename.substr(filename.find_last_of('.') + 1); std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower); return extension == "flac"; diff --git a/src/SFML/Audio/SoundFileWriterOgg.cpp b/src/SFML/Audio/SoundFileWriterOgg.cpp index c56847e5..a1f2240b 100644 --- a/src/SFML/Audio/SoundFileWriterOgg.cpp +++ b/src/SFML/Audio/SoundFileWriterOgg.cpp @@ -40,7 +40,7 @@ namespace priv //////////////////////////////////////////////////////////// bool SoundFileWriterOgg::check(const std::string& filename) { - std::string extension = filename.substr(filename.find_last_of(".") + 1); + std::string extension = filename.substr(filename.find_last_of('.') + 1); std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower); return extension == "ogg"; diff --git a/src/SFML/Audio/SoundFileWriterWav.cpp b/src/SFML/Audio/SoundFileWriterWav.cpp index 4f82d5ef..695f8377 100644 --- a/src/SFML/Audio/SoundFileWriterWav.cpp +++ b/src/SFML/Audio/SoundFileWriterWav.cpp @@ -77,7 +77,7 @@ namespace priv //////////////////////////////////////////////////////////// bool SoundFileWriterWav::check(const std::string& filename) { - std::string extension = filename.substr(filename.find_last_of(".") + 1); + std::string extension = filename.substr(filename.find_last_of('.') + 1); std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower); return extension == "wav"; diff --git a/src/SFML/Network/Ftp.cpp b/src/SFML/Network/Ftp.cpp index 6b5ebce8..54cc34fd 100644 --- a/src/SFML/Network/Ftp.cpp +++ b/src/SFML/Network/Ftp.cpp @@ -366,7 +366,7 @@ Ftp::Response Ftp::sendCommand(const std::string& command, const std::string& pa { // Build the command string std::string commandStr; - if (parameter != "") + if (!parameter.empty()) commandStr = command + " " + parameter + "\r\n"; else commandStr = command + "\r\n"; diff --git a/src/SFML/Network/Http.cpp b/src/SFML/Network/Http.cpp index 40a5167f..f9b847ec 100644 --- a/src/SFML/Network/Http.cpp +++ b/src/SFML/Network/Http.cpp @@ -327,7 +327,7 @@ void Http::setHost(const std::string& host, unsigned short port) { // HTTPS protocol -- unsupported (requires encryption and certificates and stuff...) err() << "HTTPS protocol is not supported by sf::Http" << std::endl; - m_hostName = ""; + m_hostName.clear(); m_port = 0; } else diff --git a/src/SFML/Window/WindowImpl.cpp b/src/SFML/Window/WindowImpl.cpp index d251f4eb..157d7829 100644 --- a/src/SFML/Window/WindowImpl.cpp +++ b/src/SFML/Window/WindowImpl.cpp @@ -181,7 +181,6 @@ void WindowImpl::processJoystickEvents() // Copy the previous state of the joystick and get the new one JoystickState previousState = m_joystickStates[i]; m_joystickStates[i] = JoystickManager::getInstance().getState(i); - JoystickCaps caps = JoystickManager::getInstance().getCapabilities(i); // Connection state bool connected = m_joystickStates[i].connected; @@ -199,6 +198,8 @@ void WindowImpl::processJoystickEvents() if (connected) { + JoystickCaps caps = JoystickManager::getInstance().getCapabilities(i); + // Axes for (unsigned int j = 0; j < Joystick::AxisCount; ++j) {