db/upnp: use getServer() in Visit()

Reduce bloat.
This commit is contained in:
Max Kellermann 2014-01-18 16:13:33 +01:00
parent 7d696a7063
commit 0c2485e86c
1 changed files with 9 additions and 17 deletions

View File

@ -678,12 +678,12 @@ UpnpDatabase::Visit(const DatabaseSelection &selection,
VisitPlaylist visit_playlist, VisitPlaylist visit_playlist,
Error &error) const Error &error) const
{ {
std::vector<ContentDirectoryService> servers;
if (!m_superdir->getDirServices(servers, error))
return false;
auto vpath = stringToTokens(selection.uri, "/", true); auto vpath = stringToTokens(selection.uri, "/", true);
if (vpath.empty()) { if (vpath.empty()) {
std::vector<ContentDirectoryService> servers;
if (!m_superdir->getDirServices(servers, error))
return false;
if (!selection.recursive) { if (!selection.recursive) {
// If the path is empty and recursive is not set, synthetize a // If the path is empty and recursive is not set, synthetize a
// pseudo-directory from the list of servers. // pseudo-directory from the list of servers.
@ -709,19 +709,11 @@ UpnpDatabase::Visit(const DatabaseSelection &selection,
std::string servername(vpath[0]); std::string servername(vpath[0]);
vpath.erase(vpath.begin()); vpath.erase(vpath.begin());
ContentDirectoryService *server = 0; ContentDirectoryService server;
for (auto& dir : servers) { if (!m_superdir->getServer(servername.c_str(), server, error))
if (!servername.compare(dir.getFriendlyName())) { return false;
server = &dir;
break; return VisitServer(server, vpath, selection,
}
}
if (server == 0) {
FormatDebug(db_domain, "UpnpDatabase::Visit: server %s not found\n",
vpath[0].c_str());
return true;
}
return VisitServer(*server, vpath, selection,
visit_directory, visit_song, visit_playlist, error); visit_directory, visit_song, visit_playlist, error);
} }