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()
|
const std::vector<const char*>& VulkanImplX11::getGraphicsRequiredInstanceExtensions()
|
||||||
{
|
{
|
||||||
static std::vector<const char*> extensions;
|
static const std::vector<const char*> extensions{VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_XLIB_SURFACE_EXTENSION_NAME};
|
||||||
|
|
||||||
if (extensions.empty())
|
|
||||||
{
|
|
||||||
extensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
|
|
||||||
extensions.push_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
return extensions;
|
return extensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,14 +59,12 @@ VideoMode VideoMode::getDesktopMode()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
const std::vector<VideoMode>& VideoMode::getFullscreenModes()
|
const std::vector<VideoMode>& VideoMode::getFullscreenModes()
|
||||||
{
|
{
|
||||||
static std::vector<VideoMode> modes;
|
static const auto modes = []
|
||||||
|
|
||||||
// Populate the array on first call
|
|
||||||
if (modes.empty())
|
|
||||||
{
|
{
|
||||||
modes = priv::VideoModeImpl::getFullscreenModes();
|
std::vector<VideoMode> result = priv::VideoModeImpl::getFullscreenModes();
|
||||||
std::sort(modes.begin(), modes.end(), std::greater<VideoMode>());
|
std::sort(result.begin(), result.end(), std::greater<VideoMode>());
|
||||||
}
|
return result;
|
||||||
|
}();
|
||||||
|
|
||||||
return modes;
|
return modes;
|
||||||
}
|
}
|
||||||
|
@ -183,14 +183,7 @@ VulkanFunctionPointer VulkanImplWin32::getFunction(const char* name)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
const std::vector<const char*>& VulkanImplWin32::getGraphicsRequiredInstanceExtensions()
|
const std::vector<const char*>& VulkanImplWin32::getGraphicsRequiredInstanceExtensions()
|
||||||
{
|
{
|
||||||
static std::vector<const char*> extensions;
|
static const std::vector<const char*> extensions{VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_WIN32_SURFACE_EXTENSION_NAME};
|
||||||
|
|
||||||
if (extensions.empty())
|
|
||||||
{
|
|
||||||
extensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
|
|
||||||
extensions.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
return extensions;
|
return extensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user