From 10abb07960071544778bb8abd1456b701834958e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 10 Jan 2014 21:04:54 +0100 Subject: db/upnp/Directory: make "attributes" a local variable We only need it inside StartElement(). Reduces bloat. --- src/db/upnp/Directory.cxx | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/db/upnp/Directory.cxx b/src/db/upnp/Directory.cxx index 81e01f216..1ce52aa36 100644 --- a/src/db/upnp/Directory.cxx +++ b/src/db/upnp/Directory.cxx @@ -56,7 +56,6 @@ class UPnPDirParser final : public CommonExpatParser { struct StackEl { StackEl(const std::string& nm) : name(nm) {} std::string name; - std::map attributes; }; std::vector m_path; @@ -73,17 +72,18 @@ protected: virtual void StartElement(const XML_Char *name, const XML_Char **attrs) { m_path.push_back(StackEl(name)); - for (int i = 0; attrs[i] != 0; i += 2) { - m_path.back().attributes[attrs[i]] = attrs[i+1]; - } + + std::map attributes; + for (int i = 0; attrs[i] != 0; i += 2) + attributes[attrs[i]] = attrs[i+1]; switch (name[0]) { case 'c': if (!strcmp(name, "container")) { m_tobj.clear(); m_tobj.type = UPnPDirObject::Type::CONTAINER; - m_tobj.m_id = m_path.back().attributes["id"]; - m_tobj.m_pid = m_path.back().attributes["parentID"]; + m_tobj.m_id = attributes["id"]; + m_tobj.m_pid = attributes["parentID"]; } break; @@ -91,8 +91,8 @@ protected: if (!strcmp(name, "item")) { m_tobj.clear(); m_tobj.type = UPnPDirObject::Type::ITEM; - m_tobj.m_id = m_path.back().attributes["id"]; - m_tobj.m_pid = m_path.back().attributes["parentID"]; + m_tobj.m_id = attributes["id"]; + m_tobj.m_pid = attributes["parentID"]; } break; @@ -102,12 +102,12 @@ protected: // bitrate="24576" duration="00:03:35" sampleFrequency="44100" // nrAudioChannels="2"> std::string s; - s="protocolInfo";m_tobj.m_props[s] = m_path.back().attributes[s]; - s="size";m_tobj.m_props[s] = m_path.back().attributes[s]; - s="bitrate";m_tobj.m_props[s] = m_path.back().attributes[s]; - s="duration";m_tobj.m_props[s] = m_path.back().attributes[s]; - s="sampleFrequency";m_tobj.m_props[s] = m_path.back().attributes[s]; - s="nrAudioChannels";m_tobj.m_props[s] = m_path.back().attributes[s]; + s="protocolInfo";m_tobj.m_props[s] = attributes[s]; + s="size";m_tobj.m_props[s] = attributes[s]; + s="bitrate";m_tobj.m_props[s] = attributes[s]; + s="duration";m_tobj.m_props[s] = attributes[s]; + s="sampleFrequency";m_tobj.m_props[s] = attributes[s]; + s="nrAudioChannels";m_tobj.m_props[s] = attributes[s]; } break; -- cgit v1.2.3