From 54348561362f23b709c04d3e5deac9694698d784 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 21 Jan 2014 22:46:47 +0100 Subject: db/upnp: use std::list instead of std::vector Reduce overhead. --- src/db/UpnpDatabasePlugin.cxx | 13 +++++++------ src/db/upnp/Util.cxx | 4 ++-- src/db/upnp/Util.hxx | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) (limited to 'src/db') diff --git a/src/db/UpnpDatabasePlugin.cxx b/src/db/UpnpDatabasePlugin.cxx index 7e2bfb2f6..3b9615295 100644 --- a/src/db/UpnpDatabasePlugin.cxx +++ b/src/db/UpnpDatabasePlugin.cxx @@ -105,7 +105,7 @@ protected: private: bool VisitServer(ContentDirectoryService &server, - const std::vector &vpath, + const std::list &vpath, const DatabaseSelection &selection, VisitDirectory visit_directory, VisitSong visit_song, @@ -129,7 +129,7 @@ private: Error &error) const; bool Namei(ContentDirectoryService &server, - const std::vector &vpath, + const std::list &vpath, UPnPDirObject &dirent, 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)) return nullptr; - vpath.erase(vpath.begin()); + vpath.pop_front(); + UPnPDirObject dirent; if (vpath.front() != rootid) { 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. bool UpnpDatabase::Namei(ContentDirectoryService &server, - const std::vector &vpath, + const std::list &vpath, UPnPDirObject &odirent, Error &error) const { @@ -528,7 +529,7 @@ UpnpDatabase::Namei(ContentDirectoryService &server, // really just one path parameter. bool UpnpDatabase::VisitServer(ContentDirectoryService &server, - const std::vector &vpath, + const std::list &vpath, const DatabaseSelection &selection, VisitDirectory visit_directory, VisitSong visit_song, @@ -706,7 +707,7 @@ UpnpDatabase::Visit(const DatabaseSelection &selection, // We do have a path: the first element selects the server std::string servername(std::move(vpath.front())); - vpath.erase(vpath.begin()); + vpath.pop_front(); ContentDirectoryService server; if (!m_superdir->getServer(servername.c_str(), server, error)) diff --git a/src/db/upnp/Util.cxx b/src/db/upnp/Util.cxx index fc9ef6281..383e23074 100644 --- a/src/db/upnp/Util.cxx +++ b/src/db/upnp/Util.cxx @@ -88,11 +88,11 @@ path_getfather(const std::string &s) return father; } -std::vector +std::list stringToTokens(const std::string &str, const char *delims, bool skipinit) { - std::vector tokens; + std::list tokens; std::string::size_type startPos = 0; diff --git a/src/db/upnp/Util.hxx b/src/db/upnp/Util.hxx index ba5633331..5812c5d9f 100644 --- a/src/db/upnp/Util.hxx +++ b/src/db/upnp/Util.hxx @@ -23,7 +23,7 @@ #include "Compiler.h" #include -#include +#include std::string caturl(const std::string& s1, const std::string& s2); @@ -36,7 +36,7 @@ std::string path_getfather(const std::string &s); gcc_pure -std::vector +std::list stringToTokens(const std::string &str, const char *delims = "/", bool skipinit = true); -- cgit v1.2.3