diff --git a/src/lib/upnp/Discovery.cxx b/src/lib/upnp/Discovery.cxx index 752eb8c71..4cfbf85f4 100644 --- a/src/lib/upnp/Discovery.cxx +++ b/src/lib/upnp/Discovery.cxx @@ -246,15 +246,12 @@ UPnPDeviceDirectory::ExpireDevices() const auto now = std::chrono::steady_clock::now(); bool didsomething = false; - for (auto it = directories.begin(); - it != directories.end();) { - if (now > it->expires) { - it = directories.erase(it); - didsomething = true; - } else { - it++; - } - } + directories.remove_if([now, &didsomething](const ContentDirectoryDescriptor &d){ + bool expired = now > d.expires; + if (expired) + didsomething = true; + return expired; + }); if (didsomething) Search();