db/upnp: cache m_path.back()

This commit is contained in:
Max Kellermann 2014-01-18 15:44:41 +01:00
parent f33f891c54
commit 5409e43fb5
2 changed files with 18 additions and 16 deletions

View File

@ -55,43 +55,44 @@ protected:
} }
virtual void CharacterData(const XML_Char *s, int len) { virtual void CharacterData(const XML_Char *s, int len) {
const auto &current = m_path.back();
std::string str = trimstring(s, len); std::string str = trimstring(s, len);
switch (m_path.back()[0]) { switch (current[0]) {
case 'c': case 'c':
if (!m_path.back().compare("controlURL")) if (!current.compare("controlURL"))
m_tservice.controlURL = std::move(str); m_tservice.controlURL = std::move(str);
break; break;
case 'd': case 'd':
if (!m_path.back().compare("deviceType")) if (!current.compare("deviceType"))
m_device.deviceType = std::move(str); m_device.deviceType = std::move(str);
break; break;
case 'e': case 'e':
if (!m_path.back().compare("eventSubURL")) if (!current.compare("eventSubURL"))
m_tservice.eventSubURL = std::move(str); m_tservice.eventSubURL = std::move(str);
break; break;
case 'f': case 'f':
if (!m_path.back().compare("friendlyName")) if (!current.compare("friendlyName"))
m_device.friendlyName = std::move(str); m_device.friendlyName = std::move(str);
break; break;
case 'm': case 'm':
if (!m_path.back().compare("manufacturer")) if (!current.compare("manufacturer"))
m_device.manufacturer = std::move(str); m_device.manufacturer = std::move(str);
else if (!m_path.back().compare("modelName")) else if (!current.compare("modelName"))
m_device.modelName = std::move(str); m_device.modelName = std::move(str);
break; break;
case 's': case 's':
if (!m_path.back().compare("serviceType")) if (!current.compare("serviceType"))
m_tservice.serviceType = std::move(str); m_tservice.serviceType = std::move(str);
else if (!m_path.back().compare("serviceId")) else if (!current.compare("serviceId"))
m_tservice.serviceId = std::move(str); m_tservice.serviceId = std::move(str);
case 'S': case 'S':
if (!m_path.back().compare("SCPDURL")) if (!current.compare("SCPDURL"))
m_tservice.SCPDURL = std::move(str); m_tservice.SCPDURL = std::move(str);
break; break;
case 'U': case 'U':
if (!m_path.back().compare("UDN")) if (!current.compare("UDN"))
m_device.UDN = std::move(str); m_device.UDN = std::move(str);
else if (!m_path.back().compare("URLBase")) else if (!current.compare("URLBase"))
m_device.URLBase = std::move(str); m_device.URLBase = std::move(str);
break; break;
} }

View File

@ -156,10 +156,11 @@ protected:
virtual void CharacterData(const XML_Char *s, int len) virtual void CharacterData(const XML_Char *s, int len)
{ {
const auto &current = m_path.back();
std::string str = trimstring(s, len); std::string str = trimstring(s, len);
TagType type = tag_table_lookup(upnp_tags, TagType type = tag_table_lookup(upnp_tags,
m_path.back().c_str()); current.c_str());
if (type != TAG_NUM_OF_ITEM_TYPES) { if (type != TAG_NUM_OF_ITEM_TYPES) {
tag.AddItem(type, str.c_str()); tag.AddItem(type, str.c_str());
@ -169,14 +170,14 @@ protected:
return; return;
} }
switch (m_path.back()[0]) { switch (current[0]) {
case 'r': case 'r':
if (!m_path.back().compare("res")) { if (!current.compare("res")) {
m_tobj.url = std::move(str); m_tobj.url = std::move(str);
} }
break; break;
case 'u': case 'u':
if (m_path.back() == "upnp:class") { if (current == "upnp:class") {
m_tobj.item_class = ParseItemClass(str.c_str()); m_tobj.item_class = ParseItemClass(str.c_str());
break; break;
} }