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.
This commit is contained in:
parent
f23b47ba17
commit
74842fd6d4
@ -294,24 +294,24 @@ upnpDurationToSeconds(const std::string &duration)
|
|||||||
static Song *
|
static Song *
|
||||||
upnpItemToSong(const UPnPDirObject &dirent, const char *uri)
|
upnpItemToSong(const UPnPDirObject &dirent, const char *uri)
|
||||||
{
|
{
|
||||||
std::string url(uri);
|
if (*uri == 0)
|
||||||
if (url.empty())
|
uri = dirent.getprop("url");
|
||||||
dirent.getprop("url", url);
|
|
||||||
|
|
||||||
Song *s = Song::NewFile(url.c_str(), nullptr);
|
Song *s = Song::NewFile(uri, nullptr);
|
||||||
|
|
||||||
std::string sprop("0:0:0");
|
|
||||||
dirent.getprop("duration", sprop);
|
|
||||||
int seconds = upnpDurationToSeconds(sprop);
|
|
||||||
|
|
||||||
TagBuilder tag;
|
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());
|
tag.AddItem(TAG_TITLE, titleToPathElt(dirent.m_title).c_str());
|
||||||
|
|
||||||
for (auto i = upnp_tags; i->name != nullptr; ++i)
|
for (auto i = upnp_tags; i->name != nullptr; ++i) {
|
||||||
if (dirent.getprop(i->name, sprop))
|
const char *value = dirent.getprop(i->name);
|
||||||
tag.AddItem(i->type, sprop.c_str());
|
if (value != nullptr)
|
||||||
|
tag.AddItem(i->type, value);
|
||||||
|
}
|
||||||
|
|
||||||
s->tag = tag.CommitNew();
|
s->tag = tag.CommitNew();
|
||||||
return s;
|
return s;
|
||||||
@ -378,11 +378,11 @@ getTagValue(UPnPDirObject& dirent, TagType tag,
|
|||||||
if (name == nullptr)
|
if (name == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::string propvalue;
|
const char *value = dirent.getprop(name);
|
||||||
dirent.getprop(name, propvalue);
|
if (value == nullptr)
|
||||||
if (propvalue.empty())
|
|
||||||
return false;
|
return false;
|
||||||
tagvalue = propvalue;
|
|
||||||
|
tagvalue = value;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,13 +56,11 @@ public:
|
|||||||
* @param[out] value
|
* @param[out] value
|
||||||
* @return true if found.
|
* @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);
|
auto it = m_props.find(name);
|
||||||
if (it == m_props.end())
|
if (it == m_props.end())
|
||||||
return false;
|
return nullptr;
|
||||||
value = it->second;
|
return it->second.c_str();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear()
|
void clear()
|
||||||
|
Loading…
Reference in New Issue
Block a user