From dadd987bf441324bf8824c16f3ac0798da652083 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 10 Jan 2014 21:24:12 +0100 Subject: db/upnp/Directory: move "res" attributes to array Reduce bloat. --- src/db/upnp/Directory.cxx | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/db/upnp/Directory.cxx b/src/db/upnp/Directory.cxx index 50fbb26f5..ed08eb022 100644 --- a/src/db/upnp/Directory.cxx +++ b/src/db/upnp/Directory.cxx @@ -37,6 +37,16 @@ static const char *const upnptags[] = { nullptr, }; +static const char *const res_attributes[] = { + "protocolInfo", + "size", + "bitrate", + "duration", + "sampleFrequency", + "nrAudioChannels", + nullptr, +}; + gcc_pure static UPnPDirObject::ItemClass ParseItemClass(const char *name) @@ -96,13 +106,11 @@ protected: // - std::string 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]; + + for (auto i = res_attributes; *i != nullptr; ++i) { + const std::string s(*i); + m_tobj.m_props[s] = attributes[s]; + } } break; -- cgit v1.2.3