db/upnp: getTagValue() returns string pointer
Reduce bloat.
This commit is contained in:
@@ -280,28 +280,22 @@ UpnpDatabase::GetSong(const char *uri, Error &error) const
|
|||||||
/**
|
/**
|
||||||
* Retrieve the value for an MPD tag from an object entry.
|
* Retrieve the value for an MPD tag from an object entry.
|
||||||
*/
|
*/
|
||||||
static bool
|
gcc_pure
|
||||||
getTagValue(const UPnPDirObject &dirent, TagType tag,
|
static const char *
|
||||||
std::string &tagvalue)
|
getTagValue(const UPnPDirObject &dirent, TagType tag)
|
||||||
{
|
{
|
||||||
if (tag == TAG_TITLE) {
|
if (tag == TAG_TITLE) {
|
||||||
if (!dirent.m_title.empty()) {
|
if (!dirent.m_title.empty())
|
||||||
tagvalue = dirent.m_title;
|
return dirent.m_title.c_str();
|
||||||
return true;
|
|
||||||
}
|
return nullptr;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *name = tag_table_lookup(upnp_tags, tag);
|
const char *name = tag_table_lookup(upnp_tags, tag);
|
||||||
if (name == nullptr)
|
if (name == nullptr)
|
||||||
return false;
|
return nullptr;
|
||||||
|
|
||||||
const char *value = dirent.getprop(name);
|
return dirent.getprop(name);
|
||||||
if (value == nullptr)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
tagvalue = value;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -818,12 +812,12 @@ UpnpDatabase::VisitUniqueTags(const DatabaseSelection &selection,
|
|||||||
dirent.item_class != UPnPDirObject::ItemClass::MUSIC)
|
dirent.item_class != UPnPDirObject::ItemClass::MUSIC)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
std::string tagvalue;
|
const char *value = getTagValue(dirent, tag);
|
||||||
if (getTagValue(dirent, tag, tagvalue)) {
|
if (value != nullptr) {
|
||||||
#if defined(__clang__) || GCC_CHECK_VERSION(4,8)
|
#if defined(__clang__) || GCC_CHECK_VERSION(4,8)
|
||||||
values.emplace(std::move(tagvalue));
|
values.emplace(value);
|
||||||
#else
|
#else
|
||||||
values.insert(std::move(tagvalue));
|
values.insert(value);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user