diff --git a/src/SFML/Window/Unix/KeyboardImpl.cpp b/src/SFML/Window/Unix/KeyboardImpl.cpp index 49bd72bd4..71b725962 100644 --- a/src/SFML/Window/Unix/KeyboardImpl.cpp +++ b/src/SFML/Window/Unix/KeyboardImpl.cpp @@ -473,7 +473,6 @@ void ensureMapping() XkbGetNames(display.get(), XkbKeyNamesMask, descriptor); std::unordered_map nameScancodeMap = getNameScancodeMap(); - sf::Keyboard::Scancode scancode = sf::Keyboard::Scan::Unknown; for (int keycode = descriptor->min_key_code; keycode <= descriptor->max_key_code; ++keycode) { @@ -486,7 +485,7 @@ void ensureMapping() name[XkbKeyNameLength] = '\0'; const auto mappedScancode = nameScancodeMap.find(std::string(name)); - scancode = sf::Keyboard::Scan::Unknown; + auto scancode = sf::Keyboard::Scan::Unknown; if (mappedScancode != nameScancodeMap.end()) scancode = mappedScancode->second; @@ -505,7 +504,7 @@ void ensureMapping() { if (keycodeToScancode[static_cast(keycode)] == sf::Keyboard::Scan::Unknown) { - scancode = translateKeyCode(display.get(), static_cast(keycode)); + const auto scancode = translateKeyCode(display.get(), static_cast(keycode)); if (scancode != sf::Keyboard::Scan::Unknown && scancodeToKeycode[scancode] == nullKeyCode) scancodeToKeycode[scancode] = static_cast(keycode); diff --git a/src/SFML/Window/Unix/VideoModeImpl.cpp b/src/SFML/Window/Unix/VideoModeImpl.cpp index a02af9c29..3efffa522 100644 --- a/src/SFML/Window/Unix/VideoModeImpl.cpp +++ b/src/SFML/Window/Unix/VideoModeImpl.cpp @@ -57,8 +57,7 @@ std::vector VideoModeImpl::getFullscreenModes() std::vector modes; // Open a connection with the X server - const auto display = openDisplay(); - if (display) + if (const auto display = openDisplay()) { // Retrieve the default screen number const int screen = DefaultScreen(display.get()); @@ -135,8 +134,7 @@ VideoMode VideoModeImpl::getDesktopMode() VideoMode desktopMode; // Open a connection with the X server - const auto display = openDisplay(); - if (display) + if (const auto display = openDisplay()) { // Retrieve the default screen number const int screen = DefaultScreen(display.get()); diff --git a/src/SFML/Window/Win32/JoystickImpl.cpp b/src/SFML/Window/Win32/JoystickImpl.cpp index 8ebcdddd6..4834bb891 100644 --- a/src/SFML/Window/Win32/JoystickImpl.cpp +++ b/src/SFML/Window/Win32/JoystickImpl.cpp @@ -110,7 +110,6 @@ struct ConnectionCache bool connected{}; sf::Clock timer; }; -const sf::Time connectionRefreshDelay = sf::milliseconds(500); ConnectionCache connectionCache[sf::Joystick::Count]; @@ -251,7 +250,8 @@ bool JoystickImpl::isConnected(unsigned int index) if (directInput) return isConnectedDInput(index); - ConnectionCache& cache = connectionCache[index]; + ConnectionCache& cache = connectionCache[index]; + constexpr sf::Time connectionRefreshDelay = sf::milliseconds(500); if (!lazyUpdates && cache.timer.getElapsedTime() > connectionRefreshDelay) { JOYINFOEX joyInfo;