diff --git a/src/lib/xiph/ScanVorbisComment.cxx b/src/lib/xiph/ScanVorbisComment.cxx index 98d3833a7..e4132919d 100644 --- a/src/lib/xiph/ScanVorbisComment.cxx +++ b/src/lib/xiph/ScanVorbisComment.cxx @@ -29,12 +29,12 @@ * the comment value into the tag. */ static bool -vorbis_copy_comment(StringView comment, - StringView name, TagType tag_type, +vorbis_copy_comment(std::string_view comment, + std::string_view name, TagType tag_type, TagHandler &handler) noexcept { const auto value = GetVorbisCommentValue(comment, name); - if (!value.IsNull()) { + if (value.data() != nullptr) { handler.OnTag(tag_type, value); return true; } diff --git a/src/lib/xiph/VorbisComments.cxx b/src/lib/xiph/VorbisComments.cxx index 40899e145..8cd6472bf 100644 --- a/src/lib/xiph/VorbisComments.cxx +++ b/src/lib/xiph/VorbisComments.cxx @@ -68,8 +68,8 @@ vorbis_scan_comment(StringView comment, TagHandler &handler) noexcept { const auto picture_b64 = handler.WantPicture() ? GetVorbisCommentValue(comment, "METADATA_BLOCK_PICTURE") - : nullptr; - if (!picture_b64.IsNull()) + : std::string_view{}; + if (picture_b64.data() != nullptr) return ScanVorbisPicture(picture_b64, handler); ScanVorbisComment(comment, handler); diff --git a/src/tag/ReplayGainParser.cxx b/src/tag/ReplayGainParser.cxx index 60a458e76..8fed7d438 100644 --- a/src/tag/ReplayGainParser.cxx +++ b/src/tag/ReplayGainParser.cxx @@ -75,11 +75,11 @@ bool ParseReplayGainVorbis(ReplayGainInfo &info, StringView entry) noexcept { struct VorbisCommentEntry { - StringView entry; + std::string_view entry; gcc_pure - const char *operator[](StringView n) const noexcept { - return GetVorbisCommentValue(entry, n).data; + const char *operator[](std::string_view n) const noexcept { + return GetVorbisCommentValue(entry, n).data(); } }; diff --git a/src/tag/VorbisComment.cxx b/src/tag/VorbisComment.cxx index 18f441a22..1e3543d42 100644 --- a/src/tag/VorbisComment.cxx +++ b/src/tag/VorbisComment.cxx @@ -18,21 +18,19 @@ */ #include "VorbisComment.hxx" -#include "util/StringView.hxx" +#include "util/StringCompare.hxx" #include -StringView -GetVorbisCommentValue(StringView entry, StringView name) noexcept +std::string_view +GetVorbisCommentValue(std::string_view entry, std::string_view name) noexcept { assert(!name.empty()); - if (entry.StartsWithIgnoreCase(name) && - entry.size > name.size && - entry[name.size] == '=') { - entry.skip_front(name.size + 1); - return entry; - } + if (StringStartsWithIgnoreCase(entry, name) && + entry.size() > name.size() && + entry[name.size()] == '=') + return entry.substr(name.size() + 1); - return nullptr; + return {}; } diff --git a/src/tag/VorbisComment.hxx b/src/tag/VorbisComment.hxx index 4588f0211..b9802c0a8 100644 --- a/src/tag/VorbisComment.hxx +++ b/src/tag/VorbisComment.hxx @@ -20,14 +20,14 @@ #ifndef MPD_TAG_VORBIS_COMMENT_HXX #define MPD_TAG_VORBIS_COMMENT_HXX -struct StringView; +#include /** * Checks if the specified name matches the entry's name, and if yes, * returns the comment value. */ [[gnu::pure]] -StringView -GetVorbisCommentValue(StringView entry, StringView name) noexcept; +std::string_view +GetVorbisCommentValue(std::string_view entry, std::string_view name) noexcept; #endif