diff --git a/src/SFML/Window/Unix/VulkanImplX11.cpp b/src/SFML/Window/Unix/VulkanImplX11.cpp index 7b5a5426..a3d669bb 100644 --- a/src/SFML/Window/Unix/VulkanImplX11.cpp +++ b/src/SFML/Window/Unix/VulkanImplX11.cpp @@ -184,14 +184,7 @@ VulkanFunctionPointer VulkanImplX11::getFunction(const char* name) //////////////////////////////////////////////////////////// const std::vector& VulkanImplX11::getGraphicsRequiredInstanceExtensions() { - static std::vector extensions; - - if (extensions.empty()) - { - extensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME); - extensions.push_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME); - } - + static const std::vector extensions{VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_XLIB_SURFACE_EXTENSION_NAME}; return extensions; } diff --git a/src/SFML/Window/VideoMode.cpp b/src/SFML/Window/VideoMode.cpp index 9e4b3f20..7fa3bc84 100644 --- a/src/SFML/Window/VideoMode.cpp +++ b/src/SFML/Window/VideoMode.cpp @@ -59,14 +59,12 @@ VideoMode VideoMode::getDesktopMode() //////////////////////////////////////////////////////////// const std::vector& VideoMode::getFullscreenModes() { - static std::vector modes; - - // Populate the array on first call - if (modes.empty()) + static const auto modes = [] { - modes = priv::VideoModeImpl::getFullscreenModes(); - std::sort(modes.begin(), modes.end(), std::greater()); - } + std::vector result = priv::VideoModeImpl::getFullscreenModes(); + std::sort(result.begin(), result.end(), std::greater()); + return result; + }(); return modes; } diff --git a/src/SFML/Window/Win32/VulkanImplWin32.cpp b/src/SFML/Window/Win32/VulkanImplWin32.cpp index d5776429..b74f49b7 100644 --- a/src/SFML/Window/Win32/VulkanImplWin32.cpp +++ b/src/SFML/Window/Win32/VulkanImplWin32.cpp @@ -183,14 +183,7 @@ VulkanFunctionPointer VulkanImplWin32::getFunction(const char* name) //////////////////////////////////////////////////////////// const std::vector& VulkanImplWin32::getGraphicsRequiredInstanceExtensions() { - static std::vector extensions; - - if (extensions.empty()) - { - extensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME); - extensions.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME); - } - + static const std::vector extensions{VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_WIN32_SURFACE_EXTENSION_NAME}; return extensions; }