db/upnp/Discovery: eliminate full copy in getServer()
This commit is contained in:
parent
0c2485e86c
commit
0696cac50b
|
@ -262,14 +262,24 @@ UPnPDeviceDirectory::getServer(const char *friendlyName,
|
||||||
ContentDirectoryService &server,
|
ContentDirectoryService &server,
|
||||||
Error &error)
|
Error &error)
|
||||||
{
|
{
|
||||||
std::vector<ContentDirectoryService> ds;
|
// Has locking, do it before our own lock
|
||||||
if (!getDirServices(ds, error))
|
if (!expireDevices(error))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (const auto &i : ds) {
|
const ScopeLock protect(mutex);
|
||||||
if (strcmp(friendlyName, i.getFriendlyName()) == 0) {
|
|
||||||
server = i;
|
for (const auto &i : directories) {
|
||||||
return true;
|
const auto &device = i.second.device;
|
||||||
|
|
||||||
|
if (device.friendlyName != friendlyName)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (const auto &service : device.services) {
|
||||||
|
if (isCDService(service.serviceType.c_str())) {
|
||||||
|
server = ContentDirectoryService(device,
|
||||||
|
service);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,9 +107,7 @@ public:
|
||||||
bool getDirServices(std::vector<ContentDirectoryService> &, Error &);
|
bool getDirServices(std::vector<ContentDirectoryService> &, Error &);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get server by friendly name. It's a bit wasteful to copy
|
* Get server by friendly name.
|
||||||
* all servers for this, we could directly walk the list. Otoh
|
|
||||||
* there isn't going to be millions...
|
|
||||||
*/
|
*/
|
||||||
bool getServer(const char *friendlyName,
|
bool getServer(const char *friendlyName,
|
||||||
ContentDirectoryService &server,
|
ContentDirectoryService &server,
|
||||||
|
|
Loading…
Reference in New Issue