Utilize algorithms from std::ranges

The result is shorter code and improves readability.
Note that `asConst()` is still required for non-const containers, otherwise the container will
detach.

PR #23342.
This commit is contained in:
Chocobo1
2025-10-07 01:56:08 +08:00
committed by GitHub
parent 4181a10542
commit d5d690cace
37 changed files with 95 additions and 103 deletions

View File

@@ -980,7 +980,7 @@ void AppController::setPreferencesAction()
const QString ifaceValue {it.value().toString()};
const QList<QNetworkInterface> ifaces = QNetworkInterface::allInterfaces();
const auto ifacesIter = std::find_if(ifaces.cbegin(), ifaces.cend(), [&ifaceValue](const QNetworkInterface &iface)
const auto ifacesIter = std::ranges::find_if(ifaces, [&ifaceValue](const QNetworkInterface &iface)
{
return (!iface.addressEntries().isEmpty()) && (iface.name() == ifaceValue);
});