aboutsummaryrefslogtreecommitdiffstats
path: root/src/db/plugins/upnp/Directory.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-09-30 22:03:01 +0200
committerMax Kellermann <max@duempel.org>2015-09-30 22:21:46 +0200
commit356c829b767863512da1792c048f6ddbeb8457a3 (patch)
tree7b71365eb164719ddf12d081766520ee4938bc28 /src/db/plugins/upnp/Directory.cxx
parentffbb5c48ed3edaeb72b26b61637eb3bd1cea9e32 (diff)
downloadmpd-356c829b767863512da1792c048f6ddbeb8457a3.tar.gz
mpd-356c829b767863512da1792c048f6ddbeb8457a3.tar.xz
mpd-356c829b767863512da1792c048f6ddbeb8457a3.zip
util/StringView: new utility class
Diffstat (limited to 'src/db/plugins/upnp/Directory.cxx')
-rw-r--r--src/db/plugins/upnp/Directory.cxx19
1 files changed, 5 insertions, 14 deletions
diff --git a/src/db/plugins/upnp/Directory.cxx b/src/db/plugins/upnp/Directory.cxx
index 894a53c6a..e7f92432a 100644
--- a/src/db/plugins/upnp/Directory.cxx
+++ b/src/db/plugins/upnp/Directory.cxx
@@ -25,6 +25,7 @@
#include "tag/TagBuilder.hxx"
#include "tag/TagTable.hxx"
#include "util/NumberParser.hxx"
+#include "util/StringView.hxx"
#include <algorithm>
#include <string>
@@ -36,23 +37,13 @@ UPnPDirContent::~UPnPDirContent()
/* this destructor exists here just so it won't get inlined */
}
-gcc_pure gcc_nonnull_all
-static bool
-CompareStringLiteral(const char *literal, const char *value, size_t length)
-{
- return length == strlen(literal) &&
- memcmp(literal, value, length) == 0;
-}
-
gcc_pure
static UPnPDirObject::ItemClass
-ParseItemClass(const char *name, size_t length)
+ParseItemClass(StringView name)
{
- if (CompareStringLiteral("object.item.audioItem.musicTrack",
- name, length))
+ if (name.EqualsLiteral("object.item.audioItem.musicTrack"))
return UPnPDirObject::ItemClass::MUSIC;
- else if (CompareStringLiteral("object.item.playlistItem",
- name, length))
+ else if (name.EqualsLiteral("object.item.playlistItem"))
return UPnPDirObject::ItemClass::PLAYLIST;
else
return UPnPDirObject::ItemClass::UNKNOWN;
@@ -239,7 +230,7 @@ protected:
break;
case CLASS:
- object.item_class = ParseItemClass(s, len);
+ object.item_class = ParseItemClass(StringView(s, len));
break;
}
}