db/upnp: use std::list instead of std::vector

Reduce overhead.
This commit is contained in:
Max Kellermann 2014-01-21 22:46:47 +01:00
parent aa1eb2f40d
commit 5434856136
3 changed files with 11 additions and 10 deletions

View File

@ -105,7 +105,7 @@ protected:
private: private:
bool VisitServer(ContentDirectoryService &server, bool VisitServer(ContentDirectoryService &server,
const std::vector<std::string> &vpath, const std::list<std::string> &vpath,
const DatabaseSelection &selection, const DatabaseSelection &selection,
VisitDirectory visit_directory, VisitDirectory visit_directory,
VisitSong visit_song, VisitSong visit_song,
@ -129,7 +129,7 @@ private:
Error &error) const; Error &error) const;
bool Namei(ContentDirectoryService &server, bool Namei(ContentDirectoryService &server,
const std::vector<std::string> &vpath, const std::list<std::string> &vpath,
UPnPDirObject &dirent, UPnPDirObject &dirent,
Error &error) const; Error &error) const;
@ -229,7 +229,8 @@ UpnpDatabase::GetSong(const char *uri, Error &error) const
if (!m_superdir->getServer(vpath.front().c_str(), server, error)) if (!m_superdir->getServer(vpath.front().c_str(), server, error))
return nullptr; return nullptr;
vpath.erase(vpath.begin()); vpath.pop_front();
UPnPDirObject dirent; UPnPDirObject dirent;
if (vpath.front() != rootid) { if (vpath.front() != rootid) {
if (!Namei(server, vpath, dirent, error)) if (!Namei(server, vpath, dirent, error))
@ -463,7 +464,7 @@ UpnpDatabase::BuildPath(ContentDirectoryService &server,
// Take server and internal title pathname and return objid and metadata. // Take server and internal title pathname and return objid and metadata.
bool bool
UpnpDatabase::Namei(ContentDirectoryService &server, UpnpDatabase::Namei(ContentDirectoryService &server,
const std::vector<std::string> &vpath, const std::list<std::string> &vpath,
UPnPDirObject &odirent, UPnPDirObject &odirent,
Error &error) const Error &error) const
{ {
@ -528,7 +529,7 @@ UpnpDatabase::Namei(ContentDirectoryService &server,
// really just one path parameter. // really just one path parameter.
bool bool
UpnpDatabase::VisitServer(ContentDirectoryService &server, UpnpDatabase::VisitServer(ContentDirectoryService &server,
const std::vector<std::string> &vpath, const std::list<std::string> &vpath,
const DatabaseSelection &selection, const DatabaseSelection &selection,
VisitDirectory visit_directory, VisitDirectory visit_directory,
VisitSong visit_song, VisitSong visit_song,
@ -706,7 +707,7 @@ UpnpDatabase::Visit(const DatabaseSelection &selection,
// We do have a path: the first element selects the server // We do have a path: the first element selects the server
std::string servername(std::move(vpath.front())); std::string servername(std::move(vpath.front()));
vpath.erase(vpath.begin()); vpath.pop_front();
ContentDirectoryService server; ContentDirectoryService server;
if (!m_superdir->getServer(servername.c_str(), server, error)) if (!m_superdir->getServer(servername.c_str(), server, error))

View File

@ -88,11 +88,11 @@ path_getfather(const std::string &s)
return father; return father;
} }
std::vector<std::string> std::list<std::string>
stringToTokens(const std::string &str, stringToTokens(const std::string &str,
const char *delims, bool skipinit) const char *delims, bool skipinit)
{ {
std::vector<std::string> tokens; std::list<std::string> tokens;
std::string::size_type startPos = 0; std::string::size_type startPos = 0;

View File

@ -23,7 +23,7 @@
#include "Compiler.h" #include "Compiler.h"
#include <string> #include <string>
#include <vector> #include <list>
std::string std::string
caturl(const std::string& s1, const std::string& s2); caturl(const std::string& s1, const std::string& s2);
@ -36,7 +36,7 @@ std::string
path_getfather(const std::string &s); path_getfather(const std::string &s);
gcc_pure gcc_pure
std::vector<std::string> std::list<std::string>
stringToTokens(const std::string &str, stringToTokens(const std::string &str,
const char *delims = "/", bool skipinit = true); const char *delims = "/", bool skipinit = true);