util/StringView: remove Literal()

This is not necessary, because a strlen() on a literal gets optimized
away by the compiler.
This commit is contained in:
Max Kellermann 2017-09-12 16:55:10 +02:00
parent 3491218915
commit be5b726c0a
2 changed files with 2 additions and 22 deletions

View File

@ -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;

View File

@ -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> {
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.
*/ */