File tree Expand file tree Collapse file tree 4 files changed +16
-18
lines changed Expand file tree Collapse file tree 4 files changed +16
-18
lines changed Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ CSFML_AUDIO_API bool sfSoundRecorder_isAvailable(void);
129
129
/// \return An array of strings containing the names
130
130
///
131
131
////////////////////////////////////////////////////////////
132
- CSFML_AUDIO_API const char * * sfSoundRecorder_getAvailableDevices (size_t * count );
132
+ CSFML_AUDIO_API const char * const * sfSoundRecorder_getAvailableDevices (size_t * count );
133
133
134
134
////////////////////////////////////////////////////////////
135
135
/// \brief Get the name of the default audio capture device
Original file line number Diff line number Diff line change @@ -81,18 +81,17 @@ bool sfSoundRecorder_isAvailable()
81
81
82
82
83
83
// //////////////////////////////////////////////////////////
84
- const char ** sfSoundRecorder_getAvailableDevices (size_t * count)
84
+ const char * const * sfSoundRecorder_getAvailableDevices (size_t * count)
85
85
{
86
- static std::vector<std::string> stringDevices = sf::SoundRecorder::getAvailableDevices ();
87
- static std::vector<const char *> cstringDevices;
88
-
89
- if (cstringDevices.empty () && !stringDevices.empty ())
86
+ static const auto cstringDevices = []
90
87
{
88
+ static const std::vector<std::string> stringDevices = sf::SoundRecorder::getAvailableDevices ();
89
+ std::vector<const char *> devices;
90
+ devices.reserve (stringDevices.size ());
91
91
for (const auto & stringDevice : stringDevices)
92
- {
93
- cstringDevices.push_back (stringDevice.c_str ());
94
- }
95
- }
92
+ devices.push_back (stringDevice.c_str ());
93
+ return devices;
94
+ }();
96
95
97
96
if (count)
98
97
*count = cstringDevices.size ();
@@ -104,7 +103,7 @@ const char** sfSoundRecorder_getAvailableDevices(size_t* count)
104
103
// //////////////////////////////////////////////////////////
105
104
const char * sfSoundRecorder_getDefaultDevice ()
106
105
{
107
- static std::string defaultDevice = sf::SoundRecorder::getDefaultDevice ();
106
+ static const std::string defaultDevice = sf::SoundRecorder::getDefaultDevice ();
108
107
109
108
return !defaultDevice.empty () ? defaultDevice.c_str () : nullptr ;
110
109
}
Original file line number Diff line number Diff line change @@ -41,14 +41,13 @@ sfVideoMode sfVideoMode_getDesktopMode()
41
41
// //////////////////////////////////////////////////////////
42
42
const sfVideoMode* sfVideoMode_getFullscreenModes (size_t * count)
43
43
{
44
- static std::vector<sfVideoMode> modes;
45
-
46
- // Populate the array on first call
47
- if (modes.empty ())
44
+ static const auto modes = []
48
45
{
46
+ std::vector<sfVideoMode> videomodes;
49
47
for (const auto & mode : sf::VideoMode::getFullscreenModes ())
50
- modes.push_back (convertVideoMode (mode));
51
- }
48
+ videomodes.push_back (convertVideoMode (mode));
49
+ return videomodes;
50
+ }();
52
51
53
52
if (count)
54
53
*count = modes.size ();
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ sfVulkanFunctionPointer sfVulkan_getFunction(const char* name)
52
52
// //////////////////////////////////////////////////////////
53
53
const char * const * sfVulkan_getGraphicsRequiredInstanceExtensions (size_t * count)
54
54
{
55
- static std::vector<const char *> extensions = sf::Vulkan::getGraphicsRequiredInstanceExtensions ();
55
+ static const std::vector<const char *> extensions = sf::Vulkan::getGraphicsRequiredInstanceExtensions ();
56
56
57
57
if (count)
58
58
*count = extensions.size ();
You can’t perform that action at this time.
0 commit comments