Improve static initialization of vectors
This commit is contained in:
parent
0e475f3f50
commit
e948a5f41e
@ -184,14 +184,7 @@ VulkanFunctionPointer VulkanImplX11::getFunction(const char* name)
|
||||
////////////////////////////////////////////////////////////
|
||||
const std::vector<const char*>& VulkanImplX11::getGraphicsRequiredInstanceExtensions()
|
||||
{
|
||||
static std::vector<const char*> 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<const char*> extensions{VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_XLIB_SURFACE_EXTENSION_NAME};
|
||||
return extensions;
|
||||
}
|
||||
|
||||
|
@ -59,14 +59,12 @@ VideoMode VideoMode::getDesktopMode()
|
||||
////////////////////////////////////////////////////////////
|
||||
const std::vector<VideoMode>& VideoMode::getFullscreenModes()
|
||||
{
|
||||
static std::vector<VideoMode> 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<VideoMode>());
|
||||
}
|
||||
std::vector<VideoMode> result = priv::VideoModeImpl::getFullscreenModes();
|
||||
std::sort(result.begin(), result.end(), std::greater<VideoMode>());
|
||||
return result;
|
||||
}();
|
||||
|
||||
return modes;
|
||||
}
|
||||
|
@ -183,14 +183,7 @@ VulkanFunctionPointer VulkanImplWin32::getFunction(const char* name)
|
||||
////////////////////////////////////////////////////////////
|
||||
const std::vector<const char*>& VulkanImplWin32::getGraphicsRequiredInstanceExtensions()
|
||||
{
|
||||
static std::vector<const char*> 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<const char*> extensions{VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_WIN32_SURFACE_EXTENSION_NAME};
|
||||
return extensions;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user