db/upnp/Object: disallow copying, always move
Reduce bloat.
This commit is contained in:
parent
9a4b572d34
commit
46debfb8b5
|
@ -488,7 +488,7 @@ UpnpDatabase::ReadNode(ContentDirectoryService *server,
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (dirbuf.objects.size() == 1) {
|
if (dirbuf.objects.size() == 1) {
|
||||||
dirent = dirbuf.objects[0];
|
dirent = std::move(dirbuf.objects[0]);
|
||||||
} else {
|
} else {
|
||||||
error.Format(upnp_domain, "Bad resource");
|
error.Format(upnp_domain, "Bad resource");
|
||||||
return false;
|
return false;
|
||||||
|
@ -542,8 +542,7 @@ UpnpDatabase::Namei(ContentDirectoryService* server,
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Look for the name in the sub-container list
|
// Look for the name in the sub-container list
|
||||||
const UPnPDirObject *child =
|
UPnPDirObject *child = dirbuf.FindObject(vpath[i].c_str());
|
||||||
dirbuf.FindObject(vpath[i].c_str());
|
|
||||||
if (child == nullptr)
|
if (child == nullptr)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -558,7 +557,7 @@ UpnpDatabase::Namei(ContentDirectoryService* server,
|
||||||
// The last element in the path was found and it's
|
// The last element in the path was found and it's
|
||||||
// a container, we're done
|
// a container, we're done
|
||||||
oobjid = objid;
|
oobjid = objid;
|
||||||
odirent = *child;
|
odirent = std::move(*child);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -568,7 +567,7 @@ UpnpDatabase::Namei(ContentDirectoryService* server,
|
||||||
// else it does not exist
|
// else it does not exist
|
||||||
if (i == vpath.size() - 1) {
|
if (i == vpath.size() - 1) {
|
||||||
oobjid = objid;
|
oobjid = objid;
|
||||||
odirent = *child;
|
odirent = std::move(*child);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
error.Format(db_domain, DB_NOT_FOUND,
|
error.Format(db_domain, DB_NOT_FOUND,
|
||||||
|
|
|
@ -151,7 +151,7 @@ protected:
|
||||||
{
|
{
|
||||||
if ((!strcmp(name, "container") || !strcmp(name, "item")) &&
|
if ((!strcmp(name, "container") || !strcmp(name, "item")) &&
|
||||||
checkobjok())
|
checkobjok())
|
||||||
m_dir.objects.push_back(m_tobj);
|
m_dir.objects.push_back(std::move(m_tobj));
|
||||||
|
|
||||||
m_path.pop_back();
|
m_path.pop_back();
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,8 @@ public:
|
||||||
std::vector<UPnPDirObject> objects;
|
std::vector<UPnPDirObject> objects;
|
||||||
|
|
||||||
gcc_pure
|
gcc_pure
|
||||||
const UPnPDirObject *FindObject(const char *name) const {
|
UPnPDirObject *FindObject(const char *name) {
|
||||||
for (const auto &o : objects)
|
for (auto &o : objects)
|
||||||
if (o.name == name)
|
if (o.name == name)
|
||||||
return &o;
|
return &o;
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,10 @@ public:
|
||||||
*/
|
*/
|
||||||
int duration;
|
int duration;
|
||||||
|
|
||||||
|
UPnPDirObject() = default;
|
||||||
|
UPnPDirObject(UPnPDirObject &&) = default;
|
||||||
|
UPnPDirObject &operator=(UPnPDirObject &&) = default;
|
||||||
|
|
||||||
/** Get named property
|
/** Get named property
|
||||||
* @param property name (e.g. upnp:artist, upnp:album,
|
* @param property name (e.g. upnp:artist, upnp:album,
|
||||||
* upnp:originalTrackNumber, upnp:genre). Use m_title instead
|
* upnp:originalTrackNumber, upnp:genre). Use m_title instead
|
||||||
|
|
Loading…
Reference in New Issue