Simplify some optional usage
This commit is contained in:
+3
-3
@@ -1101,7 +1101,7 @@ void alc_initconfig(void)
|
||||
if(const char *devs{getenv("ALSOFT_DRIVERS")})
|
||||
{
|
||||
if(devs[0])
|
||||
devopt = al::optional<std::string>{al::in_place, devs};
|
||||
devopt = devs;
|
||||
}
|
||||
if(devopt)
|
||||
{
|
||||
@@ -1213,7 +1213,7 @@ void alc_initconfig(void)
|
||||
InitEffect(&DefaultEffect);
|
||||
auto defrevopt = ConfigValueStr(nullptr, nullptr, "default-reverb");
|
||||
if((str=getenv("ALSOFT_DEFAULT_REVERB")) && str[0])
|
||||
defrevopt = al::optional<std::string>{al::in_place, str};
|
||||
defrevopt = str;
|
||||
if(defrevopt) LoadReverbPreset(defrevopt->c_str(), &DefaultEffect);
|
||||
}
|
||||
#define DO_INITCONFIG() std::call_once(alc_config_once, [](){alc_initconfig();})
|
||||
@@ -1373,7 +1373,7 @@ static al::optional<DevFmtPair> DecomposeDevFormat(ALenum format)
|
||||
for(const auto &item : list)
|
||||
{
|
||||
if(item.format == format)
|
||||
return al::optional<DevFmtPair>{al::in_place, DevFmtPair{item.channels, item.type}};
|
||||
return al::optional<DevFmtPair>{{item.channels, item.type}};
|
||||
}
|
||||
|
||||
return al::nullopt;
|
||||
|
||||
+5
-6
@@ -497,7 +497,7 @@ al::optional<std::string> ConfigValueStr(const char *devName, const char *blockN
|
||||
const char *val = GetConfigValue(devName, blockName, keyName, "");
|
||||
if(!val[0]) return al::nullopt;
|
||||
|
||||
return al::optional<std::string>{al::in_place, val};
|
||||
return al::optional<std::string>{val};
|
||||
}
|
||||
|
||||
al::optional<int> ConfigValueInt(const char *devName, const char *blockName, const char *keyName)
|
||||
@@ -505,7 +505,7 @@ al::optional<int> ConfigValueInt(const char *devName, const char *blockName, con
|
||||
const char *val = GetConfigValue(devName, blockName, keyName, "");
|
||||
if(!val[0]) return al::nullopt;
|
||||
|
||||
return al::optional<int>{al::in_place, static_cast<int>(std::strtol(val, nullptr, 0))};
|
||||
return al::optional<int>{static_cast<int>(std::strtol(val, nullptr, 0))};
|
||||
}
|
||||
|
||||
al::optional<unsigned int> ConfigValueUInt(const char *devName, const char *blockName, const char *keyName)
|
||||
@@ -513,8 +513,7 @@ al::optional<unsigned int> ConfigValueUInt(const char *devName, const char *bloc
|
||||
const char *val = GetConfigValue(devName, blockName, keyName, "");
|
||||
if(!val[0]) return al::nullopt;
|
||||
|
||||
return al::optional<unsigned int>{al::in_place,
|
||||
static_cast<unsigned int>(std::strtoul(val, nullptr, 0))};
|
||||
return al::optional<unsigned int>{static_cast<unsigned int>(std::strtoul(val, nullptr, 0))};
|
||||
}
|
||||
|
||||
al::optional<float> ConfigValueFloat(const char *devName, const char *blockName, const char *keyName)
|
||||
@@ -522,7 +521,7 @@ al::optional<float> ConfigValueFloat(const char *devName, const char *blockName,
|
||||
const char *val = GetConfigValue(devName, blockName, keyName, "");
|
||||
if(!val[0]) return al::nullopt;
|
||||
|
||||
return al::optional<float>{al::in_place, std::strtof(val, nullptr)};
|
||||
return al::optional<float>{std::strtof(val, nullptr)};
|
||||
}
|
||||
|
||||
al::optional<bool> ConfigValueBool(const char *devName, const char *blockName, const char *keyName)
|
||||
@@ -530,7 +529,7 @@ al::optional<bool> ConfigValueBool(const char *devName, const char *blockName, c
|
||||
const char *val = GetConfigValue(devName, blockName, keyName, "");
|
||||
if(!val[0]) return al::nullopt;
|
||||
|
||||
return al::optional<bool>{al::in_place,
|
||||
return al::optional<bool>{
|
||||
strcasecmp(val, "true") == 0 || strcasecmp(val, "yes") == 0 ||
|
||||
strcasecmp(val, "on") == 0 || atoi(val) != 0};
|
||||
}
|
||||
|
||||
@@ -402,7 +402,7 @@ al::optional<DecompResult> DecomposeUserFormat(ALenum format)
|
||||
for(const auto &fmt : UserFmtList)
|
||||
{
|
||||
if(fmt.format == format)
|
||||
return al::optional<DecompResult>{al::in_place, DecompResult{fmt.channels, fmt.type}};
|
||||
return al::optional<DecompResult>{{fmt.channels, fmt.type}};
|
||||
}
|
||||
return al::nullopt;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user