Commit be5b726c authored by Max Kellermann's avatar Max Kellermann

util/StringView: remove Literal()

This is not necessary, because a strlen() on a literal gets optimized away by the compiler.
parent 34912189
...@@ -41,9 +41,9 @@ gcc_pure ...@@ -41,9 +41,9 @@ gcc_pure
static UPnPDirObject::ItemClass static UPnPDirObject::ItemClass
ParseItemClass(StringView name) noexcept ParseItemClass(StringView name) noexcept
{ {
if (name.EqualsLiteral("object.item.audioItem.musicTrack")) if (name.Equals("object.item.audioItem.musicTrack"))
return UPnPDirObject::ItemClass::MUSIC; return UPnPDirObject::ItemClass::MUSIC;
else if (name.EqualsLiteral("object.item.playlistItem")) else if (name.Equals("object.item.playlistItem"))
return UPnPDirObject::ItemClass::PLAYLIST; return UPnPDirObject::ItemClass::PLAYLIST;
else else
return UPnPDirObject::ItemClass::UNKNOWN; return UPnPDirObject::ItemClass::UNKNOWN;
......
...@@ -54,16 +54,6 @@ struct StringView : ConstBuffer<char> { ...@@ -54,16 +54,6 @@ struct StringView : ConstBuffer<char> {
return StringView("", size_t(0)); return StringView("", size_t(0));
} }
template<size_t n>
static constexpr StringView Literal(const char (&_data)[n]) noexcept {
static_assert(n > 0, "");
return {_data, n - 1};
}
static constexpr StringView Literal() noexcept {
return StringView("", size_t(0));
}
void SetEmpty() noexcept { void SetEmpty() noexcept {
data = ""; data = "";
size = 0; size = 0;
...@@ -105,22 +95,12 @@ struct StringView : ConstBuffer<char> { ...@@ -105,22 +95,12 @@ struct StringView : ConstBuffer<char> {
memcmp(data, other.data, size) == 0; memcmp(data, other.data, size) == 0;
} }
template<size_t n>
bool EqualsLiteral(const char (&other)[n]) const noexcept {
return Equals(Literal(other));
}
gcc_pure gcc_pure
bool EqualsIgnoreCase(StringView other) const noexcept { bool EqualsIgnoreCase(StringView other) const noexcept {
return size == other.size && return size == other.size &&
strncasecmp(data, other.data, size) == 0; strncasecmp(data, other.data, size) == 0;
} }
template<size_t n>
bool EqualsLiteralIgnoreCase(const char (&other)[n]) const noexcept {
return EqualsIgnoreCase(Literal(other));
}
/** /**
* Skip all whitespace at the beginning. * Skip all whitespace at the beginning.
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment