diff options
author | Max Kellermann <max@duempel.org> | 2015-09-30 22:03:01 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2015-09-30 22:21:46 +0200 |
commit | 356c829b767863512da1792c048f6ddbeb8457a3 (patch) | |
tree | 7b71365eb164719ddf12d081766520ee4938bc28 /src/db | |
parent | ffbb5c48ed3edaeb72b26b61637eb3bd1cea9e32 (diff) | |
download | mpd-356c829b767863512da1792c048f6ddbeb8457a3.tar.gz mpd-356c829b767863512da1792c048f6ddbeb8457a3.tar.xz mpd-356c829b767863512da1792c048f6ddbeb8457a3.zip |
util/StringView: new utility class
Diffstat (limited to 'src/db')
-rw-r--r-- | src/db/plugins/upnp/Directory.cxx | 19 |
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; } } |