Simplify functions

This commit is contained in:
Chocobo1 2022-09-07 12:51:01 +08:00
parent 987e1b544a
commit 4094a4c448
No known key found for this signature in database
GPG key ID: 210D9C873253A68C
4 changed files with 17 additions and 26 deletions

View file

@ -548,10 +548,9 @@ QVector<Utils::Net::Subnet> Preferences::getWebUiAuthSubnetWhitelist() const
for (const QString &rawSubnet : subnets)
{
bool ok = false;
const Utils::Net::Subnet subnet = Utils::Net::parseSubnet(rawSubnet.trimmed(), &ok);
if (ok)
ret.append(subnet);
const std::optional<Utils::Net::Subnet> subnet = Utils::Net::parseSubnet(rawSubnet.trimmed());
if (subnet)
ret.append(subnet.value());
}
return ret;
@ -561,9 +560,7 @@ void Preferences::setWebUiAuthSubnetWhitelist(QStringList subnets)
{
Algorithm::removeIf(subnets, [](const QString &subnet)
{
bool ok = false;
Utils::Net::parseSubnet(subnet.trimmed(), &ok);
return !ok;
return !Utils::Net::parseSubnet(subnet.trimmed()).has_value();
});
setValue(u"Preferences/WebUI/AuthSubnetWhitelist"_qs, subnets);