Fix #9386: compilers failing to compile with LTO by using variants instead of new + unique_ptr

With std::variant all memory can be figured out at compile time, so the compiler needs to keep track of fewer elements. It also saves out a unique_ptr and its memory management, over a slight impact for resolving a setting.
This commit is contained in:
rubidium42
2021-06-21 18:46:27 +02:00
committed by Patric Stout
parent f35e6c1c7f
commit 98e653dacc
13 changed files with 16 additions and 14 deletions

View File

@@ -54,7 +54,7 @@ static size_t ConvertLandscape(const char *value);
* on the appropriate macro.
*/
#define NSD(type, ...) std::unique_ptr<const SettingDesc>(new type##SettingDesc(__VA_ARGS__))
#define NSD(type, ...) SettingVariant { std::in_place_type<type##SettingDesc>, __VA_ARGS__ }
/* Macros for various objects to go in the configuration file.
* This section is for global variables */

View File

@@ -12,7 +12,7 @@ static void UpdateAllServiceInterval(int32 new_value);
static bool CanUpdateServiceInterval(VehicleType type, int32 &new_value);
static void UpdateServiceInterval(VehicleType type, int32 new_value);
static const SettingTable _company_settings{
static const SettingVariant _company_settings[] = {
[post-amble]
};
[templates]

View File

@@ -7,7 +7,7 @@
; Settings for the in-game custom currency.
[pre-amble]
static const SettingTable _currency_settings{
static const SettingVariant _currency_settings[] = {
[post-amble]
};
[templates]

View File

@@ -33,7 +33,7 @@ static std::initializer_list<const char*> _osk_activation{"disabled", "double",
static std::initializer_list<const char*> _settings_profiles{"easy", "medium", "hard"};
static std::initializer_list<const char*> _news_display{ "off", "summarized", "full"};
static const SettingTable _gameopt_settings{
static const SettingVariant _gameopt_settings[] = {
/* In version 4 a new difficulty setting has been added to the difficulty settings,
* town attitude towards demolishing. Needs special handling because some dimwit thought
* it funny to have the GameDifficulty struct be an array while it is a struct of

View File

@@ -20,7 +20,7 @@ extern bool _allow_hidpi_window;
#define WITHOUT_COCOA
#endif
static const SettingTable _misc_settings{
static const SettingVariant _misc_settings[] = {
[post-amble]
};
[templates]

View File

@@ -49,7 +49,7 @@ static void UpdateClientConfigValues();
* assigns its own value. If the setting was company-based, that would mean that
* vehicles could decide on different moments that they are heading back to a
* service depot, causing desyncs on a massive scale. */
const SettingTable _settings{
static const SettingVariant _settings[] = {
[post-amble]
};
[templates]

View File

@@ -12,7 +12,7 @@
#if defined(_WIN32) && !defined(DEDICATED)
extern bool _window_maximize;
static const SettingTable _win32_settings{
static const SettingVariant _win32_settings[] = {
[post-amble]
};
#endif /* _WIN32 */

View File

@@ -9,7 +9,7 @@
[pre-amble]
static const SettingTable _window_settings{
static const SettingVariant _window_settings[] = {
[post-amble]
};
[templates]