diff options
author | Max Kellermann <max@duempel.org> | 2014-01-10 20:13:17 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-01-10 22:56:45 +0100 |
commit | 74842fd6d4d1cd35c7e80935e42d9b010751be49 (patch) | |
tree | 69f26ab05cf7167f9f84f4820420b2501e62a14f /src | |
parent | f23b47ba17e57923ca81d65770827db28d514bc9 (diff) | |
download | mpd-74842fd6d4d1cd35c7e80935e42d9b010751be49.tar.gz mpd-74842fd6d4d1cd35c7e80935e42d9b010751be49.tar.xz mpd-74842fd6d4d1cd35c7e80935e42d9b010751be49.zip |
db/upnp: getprop() returns const char *
Return the return value, instead returning it in a reference
parameter. Reduces bloat by reducing unnecessary std::string usage.
Diffstat (limited to '')
-rw-r--r-- | src/db/UpnpDatabasePlugin.cxx | 32 | ||||
-rw-r--r-- | src/db/upnp/Object.hxx | 8 |
2 files changed, 19 insertions, 21 deletions
diff --git a/src/db/UpnpDatabasePlugin.cxx b/src/db/UpnpDatabasePlugin.cxx index 69248aadf..809557de4 100644 --- a/src/db/UpnpDatabasePlugin.cxx +++ b/src/db/UpnpDatabasePlugin.cxx @@ -294,24 +294,24 @@ upnpDurationToSeconds(const std::string &duration) static Song * upnpItemToSong(const UPnPDirObject &dirent, const char *uri) { - std::string url(uri); - if (url.empty()) - dirent.getprop("url", url); + if (*uri == 0) + uri = dirent.getprop("url"); - Song *s = Song::NewFile(url.c_str(), nullptr); - - std::string sprop("0:0:0"); - dirent.getprop("duration", sprop); - int seconds = upnpDurationToSeconds(sprop); + Song *s = Song::NewFile(uri, nullptr); TagBuilder tag; - tag.SetTime(seconds); + + const char *duration = dirent.getprop("duration"); + if (duration != nullptr) + tag.SetTime(upnpDurationToSeconds(duration)); tag.AddItem(TAG_TITLE, titleToPathElt(dirent.m_title).c_str()); - for (auto i = upnp_tags; i->name != nullptr; ++i) - if (dirent.getprop(i->name, sprop)) - tag.AddItem(i->type, sprop.c_str()); + for (auto i = upnp_tags; i->name != nullptr; ++i) { + const char *value = dirent.getprop(i->name); + if (value != nullptr) + tag.AddItem(i->type, value); + } s->tag = tag.CommitNew(); return s; @@ -378,11 +378,11 @@ getTagValue(UPnPDirObject& dirent, TagType tag, if (name == nullptr) return false; - std::string propvalue; - dirent.getprop(name, propvalue); - if (propvalue.empty()) + const char *value = dirent.getprop(name); + if (value == nullptr) return false; - tagvalue = propvalue; + + tagvalue = value; return true; } diff --git a/src/db/upnp/Object.hxx b/src/db/upnp/Object.hxx index c05f39e47..4949146e8 100644 --- a/src/db/upnp/Object.hxx +++ b/src/db/upnp/Object.hxx @@ -56,13 +56,11 @@ public: * @param[out] value * @return true if found. */ - bool getprop(const std::string &name, std::string &value) const - { + const char *getprop(const char *name) const { auto it = m_props.find(name); if (it == m_props.end()) - return false; - value = it->second; - return true; + return nullptr; + return it->second.c_str(); } void clear() |