aboutsummaryrefslogtreecommitdiffstats
path: root/src/db
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-14 13:42:08 +0100
committerMax Kellermann <max@duempel.org>2014-01-14 13:42:08 +0100
commit9a4b572d3461ab8124b4f5e8e2a199907f7efd2f (patch)
treef1d1c9615823aba2fe3f180fff54ce7901102cd3 /src/db
parentddc75cc46b35639bfbb8fe014070d8948a259dad (diff)
downloadmpd-9a4b572d3461ab8124b4f5e8e2a199907f7efd2f.tar.gz
mpd-9a4b572d3461ab8124b4f5e8e2a199907f7efd2f.tar.xz
mpd-9a4b572d3461ab8124b4f5e8e2a199907f7efd2f.zip
db/upnp: getTagValue() returns string pointer
Reduce bloat.
Diffstat (limited to 'src/db')
-rw-r--r--src/db/UpnpDatabasePlugin.cxx32
1 files changed, 13 insertions, 19 deletions
diff --git a/src/db/UpnpDatabasePlugin.cxx b/src/db/UpnpDatabasePlugin.cxx
index 99cbf570a..436b22a80 100644
--- a/src/db/UpnpDatabasePlugin.cxx
+++ b/src/db/UpnpDatabasePlugin.cxx
@@ -280,28 +280,22 @@ UpnpDatabase::GetSong(const char *uri, Error &error) const
/**
* Retrieve the value for an MPD tag from an object entry.
*/
-static bool
-getTagValue(const UPnPDirObject &dirent, TagType tag,
- std::string &tagvalue)
+gcc_pure
+static const char *
+getTagValue(const UPnPDirObject &dirent, TagType tag)
{
if (tag == TAG_TITLE) {
- if (!dirent.m_title.empty()) {
- tagvalue = dirent.m_title;
- return true;
- }
- return false;
+ if (!dirent.m_title.empty())
+ return dirent.m_title.c_str();
+
+ return nullptr;
}
const char *name = tag_table_lookup(upnp_tags, tag);
if (name == nullptr)
- return false;
-
- const char *value = dirent.getprop(name);
- if (value == nullptr)
- return false;
+ return nullptr;
- tagvalue = value;
- return true;
+ return dirent.getprop(name);
}
/**
@@ -818,12 +812,12 @@ UpnpDatabase::VisitUniqueTags(const DatabaseSelection &selection,
dirent.item_class != UPnPDirObject::ItemClass::MUSIC)
continue;
- std::string tagvalue;
- if (getTagValue(dirent, tag, tagvalue)) {
+ const char *value = getTagValue(dirent, tag);
+ if (value != nullptr) {
#if defined(__clang__) || GCC_CHECK_VERSION(4,8)
- values.emplace(std::move(tagvalue));
+ values.emplace(value);
#else
- values.insert(std::move(tagvalue));
+ values.insert(value);
#endif
}
}